/**
 * 20220401
 * 勾选投保人/被保险人个人信息申明
 */
$(document).on('click', '.check-statement a.checkbox', function () {
    var $this = $(this);
    if (!$this.hasClass('checked')) {
        if ($this.attr('id')== 'check1') {
            _gsq.push(["track", "c_interact", { c_page_cate: "保单页", c_botton_cate: "保单页信息填写", c_botton_loc: "声明勾选_1", c_button_name: "声明勾选_1", c_botton_url: "-", c_pro_name: $("input[name='productName']").val() }]);
        } else if ($this.attr('id') == 'check2') {
            _gsq.push(["track", "c_interact", { c_page_cate: "保单页", c_botton_cate: "保单页信息填写", c_botton_loc: "声明勾选_2", c_button_name: "声明勾选_2", c_botton_url: "-", c_pro_name: $("input[name='productName']").val() }]);
        } else if ($this.attr('id') == 'check3') {
            _gsq.push(["track", "c_interact", { c_page_cate: "保单页", c_botton_cate: "保单页信息填写", c_botton_loc: "声明勾选_3", c_button_name: "声明勾选_3", c_botton_url: "-", c_pro_name: $("input[name='productName']").val() }]);
        }
    }
    $this.toggleClass('checked');
    if ($('.state-item-checkbox a.checkbox').length * 1 == $('.state-item-checkbox a.checkbox.checked').length * 1)
        $('.check-statement-vaild .Validform_checktip').removeClass('Validform_wrong');
    if (!$this.hasClass('checked')) {
        $('.state-item-checkbox a.checkbox').addClass('checkunll');
        $('.check-statement-vaild .Validform_checktip').addClass('Validform_wrong');
    }
})
// 提交保单，检测是否全部选中
function check_statement() {
    if ($('.state-item-checkbox a.checkbox').length * 1 != $('.state-item-checkbox a.checkbox.checked').length * 1) {
        $('.check-statement-vaild .Validform_checktip').addClass('Validform_wrong');
        layer.open({
            className: 'mxui-alert'
            , content: '<i class="icon icon-warn">&nbsp;</i>请勾选同意处理个人信息'
            , skin: 'msg'
            , time: 2
        });
        $('.state-item-checkbox a.checkbox').addClass('checkunll');

        $body.animate({
            scrollTop: $('.check-statement .state-item-checkbox').offset().top
        }, 1000);
        return false;
    }
    return true;
}
// 20220401 勾选投保人/被保险人个人信息申明 End

/**
 * 2020.0210
 * 更多信息
 */
$(document).on('click', '.layui-order-form .v2-order-step .order-more-tab a', function(){
    var $this = $(this);
    if($this.text()=='展开')
    {
        $this.text('合起');
        var container = $('.layui-order-form .v2-order-step'), scrollTo = $('#ApplicantJobIncome');
        container.animate({
            scrollTop: 1000
        }, 500)
    }
    else
        $this.text('展开');
    $this.closest('.order-more-items').toggleClass('show');
})
//调用数字键盘
$(document).on('onfocus', '.layui-order-form .v2-order-step input[rel=jobincome]', function(){
    if (/(Android)/i.test(navigator.userAgent))
        $(this).attr('type', 'number').attr('pattern', "\d");
})
//mui框架中input输入框失焦滚到页面顶部问题
$("input").on("blur", function () {
    $("body").removeClass("mui-focusin")
})
/**
 * =====2019.11.1
 * 购买页头部
 * 其他修改：
 * 1、投保人信息、被保人信息展示
 * 2、被保人出生日期规则最大限制55周岁
 * 3、被保人出生日期规则最大限制18周岁（根据保单生效日期，可选17岁）
 *
 */
var order_PlanName = $('#PlanName').val();
var order_PolicyStartDate = $('#PolicyStartDate').val();

//Add by Xu Lei at 2020.11.02 for 添加百万医疗DTC Start
if ($("input[name='ProductCode']").val() == '180301' || $("input[name='ProductCode']").val() == '180302' || $("input[name='ProductCode']").val() == '18030101') {
    order_PolicyStartDate = moment().add(3, 'day').format('YYYY-MM-DD');
}
//Add by Xu Lei at 2020.11.02 for 添加百万医疗DTC End

// Update 2022.01.05 for 一生康美 Start
// 查看职业与类别
$('.btn-jobcareer').click(function () {
    var tempcontent = $('#iframe_tpl-jobcareer').html();
    layer.open({
        className: 'layui-order-iframe  page-baozhang-content'
        , title: [
            '<a href="javascript:;" class="layui-iframe-close">关闭</a>特殊职业分类表',
            'background-color:#efefef;height:1.75rem;line-height:1.75rem;color:#1352de;font-size:.6rem;'
        ]
        , type: 1
        , content: tempcontent
        , anim: 'up'
        , style: 'position:fixed; bottom:0; left:0; width: 100%; height: 100%; padding:10px 0; border:none;'
    });
});
// 健康告知
$(document).on('click', '.btn-agreen-gaozhi', function () {
    layer.open({
        className: 'layer-content-full layui-order-iframe'
        , title: [
            '被保险人健康状况告知',
            'background-color:#fff;height:1.75rem;line-height:1.75rem;color:#001871;font-size:.6rem;position:relative;border-bottom:1px solid #f2f2f2;text-align:center!important;text-indent:0;'
        ]
        , type: 1
        , anim: 'up'
        , scrollbar: false
        , style: 'position:fixed; bottom:0; left:0; width: 100%; height: 100%; padding:10px 0; border:none;'
        , content: $('#tpl-health').html()
    });
})
// Update 2022.01.05 for 一生康美 End

$(document).on('click', '.layui-order-form input[rel=livecity],.layui-order-form input[rel=area]',function () {
    document.activeElement.blur();
});
var targetCity, targetJob;
function picker_livecity() {
    // Update 2022.01.05 for 一生康美 Start
    var $this2 = $('.layui-order-form input[rel=area]');
    if ($this2.attr('id') == 'ApplicantArea') {
        targetCity = new MultiPicker({
            input: 'ApplicantArea',//点击触发插件的input框的id
            container: 'targetAreaContainer',//插件插入的容器id
            jsonData: $area,
            success: function (arr) {
                $('.layui-order-form input[rel=area]').val(arr[0].value).removeClass('Validform_error Validform_error2');
                delete (targetCity);
            }//回调
        })
    }
    // Update 2022.01.05 for 一生康美 End

    var $this = $('.layui-order-form input[rel=livecity]');
    if ($this.attr('id') == 'ApplicantLiveCity') {
        targetCity = new MultiPicker({
            input: 'ApplicantLiveCity',//点击触发插件的input框的id
            container: 'targetCityContainer',//插件插入的容器id
            jsonData: $city,
            success: function (arr) {
                // update by meixuan 2023.10.20
                $('.layui-order-form input[rel=livecity]').val(arr[0].value + ' / ' + arr[1].value + ' / ' + arr[2].value).removeClass('Validform_error Validform_error2');
                delete (targetCity);
            }//回调
        })
    } else {
        if ($('.layui-order-form #InsuredLivecity').attr('disabled') != undefined)
            return false;
        targetCity = new MultiPicker({
            input: 'InsuredLiveCity',//点击触发插件的input框的id
            container: 'targetCityContainer',//插件插入的容器id
            jsonData: $city,
            success: function (arr) {
                // update by meixuan 2023.10.20
                $('.layui-order-form input[rel=livecity]').val(arr[0].value + ' / ' + arr[1].value + ' / ' + arr[2].value).removeClass('Validform_error Validform_error2');
                delete (targetCity);
            }//回调
        })
    }
}
$(document).on('click', '.layui-order-form input[rel=jobcareer]', function () {
    document.activeElement.blur();
});
function picker_jobcareer() {
    var $this = $('.layui-order-form input[rel=jobcareer]');
    if ($this.attr('id') == 'ApplicantJobCareer') {
        targetJob = new MultiPicker({
            input: 'ApplicantJobCareer',//点击触发插件的input框的id
            container: 'targetJobContainer',//插件插入的容器id
            jsonData: $jobs_applicant,
            success: function (arr) {
                console.log(arr[1].value);
                $('.layui-order-form input[rel=jobcareer]').val(arr[1].value).removeClass('Validform_error Validform_error2');
                delete (targetJob);
            }//回调
        })
    } else {
        targetJob = new MultiPicker({
            input: 'InsuredJobCareer',//点击触发插件的input框的id
            container: 'targetJobContainer',//插件插入的容器id
            jsonData: $jobs,
            success: function (arr) {
                console.log(arr[1].value);
                $('.layui-order-form input[rel=jobcareer]').val(arr[1].value).removeClass('Validform_error Validform_error2');
                delete (targetJob);
            }//回调
        })
    }
}
var msglayer;
// 无业，判断计划是否为无忧计划，否则报错
function checkPlan(job) {
    // UP：2020.02.22 职业可为空，取消判断
    /*if(job.length==0){
        msglayer = layer.open({
            className: 'layui-order-tip'
            , title: [
                '提示<a href="javascript:;" class="layui-msg-close"></a>',
                'background-color:#f1f9ff;color:#fff;border-radius:0;color:#333;font-size:.6rem;height:1.75rem;line-height:1.75rem;'
            ]
            , anim: 'up'
            , content: '<p style="font-size:.6rem;color:#333;text-align:center;padding:1.25rem 0;"><img src="/MImg/order_ah/icon-order-msg-error.png" style="display:block;width:2.1rem;margin:0 auto 0.6rem;">请选择可投保职业与类别</p>'
        })
        return false;
    }*/
    if(job.indexOf('无业') >= 0 && '无忧计划'!=order_PlanName){
        msglayer = layer.open({
            className: 'layui-order-tip'
            , title: [
                '提示<a href="javascript:;" class="layui-msg-close"></a>',
                'background-color:#f1f9ff;color:#fff;border-radius:0;color:#333;font-size:.6rem;height:1.75rem;line-height:1.75rem;'
            ]
            , anim: 'up'
            , content: '<p style="font-size:.6rem;color:#333;text-align:center;padding:1.25rem 0;"><img src="/MImg/order_ah/icon-order-msg-error.png" style="display:block;width:2.1rem;margin:0 auto 0.6rem;">被保险人为无业人员仅可投保“无忧计划”<br><span style="color:#fe8a01;">请更改被保险人职业类别或单独投保</span></p>'
        })
        return false;
    }
    // 投保人职业选择其他，被保人本人报错
    if (job.indexOf('其他') >= 0) {
        msglayer = layer.open({
            className: 'layui-order-tip'
            , title: [
                '提示<a href="javascript:;" class="layui-msg-close"></a>',
                'background-color:#f1f9ff;color:#fff;border-radius:0;color:#333;font-size:.6rem;height:1.75rem;line-height:1.75rem;'
            ]
            , anim: 'up'
            , content: '<p style="font-size:.6rem;color:#333;text-align:center;padding:1.25rem 0;"><img src="/MImg/order_ah/icon-order-msg-error.png" style="display:block;width:2.1rem;margin:0 auto 0.6rem;">被保险人职业不在投保范围</p>'
        })
        return false;
    }
    return true;
}
function checkInsuredAge() {
    var res = 1;
    var obj = $('.layui-order-form input[rel=age]');
    if (obj.length > 0) {
        //被保人出生日期
        var thisBirthday = moment(obj.val()).format('YYYY-MM-DD');
        var HidminOld = $("#HidminOld").val();
        var HidmaxOld = $("#HidmaxOld").val();
        if (thisBirthday.length == 10) {
            //系统当天日期
            var t1 = moment().format('YYYY-MM-DD');
            //保单开始日期
            var t2 = order_PolicyStartDate;
            //系统当天时间和保单开始时间差几天
            var diff_days = moment(t2).diff(t1, 'days');
            var thisBirthday1 = moment(thisBirthday).add(-diff_days, 'day').format('YYYY-MM-DD');
            var thisBirthday2 = moment(thisBirthday).add(diff_days, 'day').format('YYYY-MM-DD');
            var age1 = GetAge(thisBirthday1);
            console.log(age1);
            var age2 = GetAge(thisBirthday2);
            console.log(age2);
            //Add by Amy at 2021.06.01 for 添加宝贝无忧 Start
            //Update by Xu Lei at 2020.11.02 for 添加百万医疗DTC Start
            if ($("input[name='ProductCode']").val() == '180301' || $("input[name='ProductCode']").val() == '180302' || $("input[name='ProductCode']").val() == '18030101' || $("input[name='ProductCode']").val() == '020606' || $("input[name='ProductCode']").val() == '0206063' || $("input[name='ProductCode']").val() == '0206062') {  //Add by Qufeng at 2021/10/21 新增赠险ProductCode
                if (age1 != 0 && HidmaxOld < age1)
                    res = 0;

                // 判断小于1岁的被保险人年龄的天数+保单生效日相差天数 = 保单生效日被保险人实际出生天数
                var birthday_days = moment(t1).diff(thisBirthday, 'days') * 1 + diff_days * 1;
                if (birthday_days < 30)
                    res = 0;
            } else {
                if (age2 > HidminOld) {
                    if (HidmaxOld < age1)
                        res = 0;
                    if (HidminOld > age2)
                        res = 0;
                }
            }
            //Update by Xu Lei at 2020.11.02 for 添加百万医疗DTC End
            //Add by Amy at 2021.06.01 for 添加宝贝无忧 End
        }
    }
    if (!res) {

        // Update 2022.01.05 for 一生康美 Start
        var min = $("#HidminOld").val();
        if ($("input[name='ProductCode']").val() == '180301' || $("input[name='ProductCode']").val() == '18030101' || $("input[name='ProductCode']").val() == '180302' || $("input[name='ProductCode']").val() == '020606' || $("input[name='ProductCode']").val() == '0206062') {
            min = '30天';
        }
        msglayer = layer.open({
            className: 'layui-order-tip'
            , title: [
                '提示<a href="javascript:;" class="layui-msg-close close"></a>',
                'background-color:#f1f9ff;color:#fff;border-radius:0;color:#333;font-size:.6rem;height:1.75rem;line-height:1.75rem;'
            ]
            , anim: 'up'
            , content: '<p style="font-size:.6rem;color:#333;text-align:center;padding:1.25rem 0;"><img src="https://mall.aig.com.cn/MImg/order_ah/icon-order-msg-error.png" style="display:block;width:2.1rem;margin:0 auto 0.6rem;">被保险人年龄须为' + min + '-' + $("#HidmaxOld").val() + '周岁<br><span style="color:#fe8a01;">被保险人年龄不在投保范围</span></p>'
        })
        // Update 2022.01.05 for 一生康美 End
        return false;
    }
    return true;


    ///**
    // * @param strBirthday：指的是出生日期，格式为"1990-01-01"
    // */
    function GetAge(strBirthday) {
        var returnAge,
            strBirthdayArr = strBirthday.split("-"),
            birthYear = strBirthdayArr[0],
            birthMonth = strBirthdayArr[1],
            birthDay = strBirthdayArr[2],
            d = new Date(),
            nowYear = d.getFullYear(),
            nowMonth = d.getMonth() + 1,
            nowDay = d.getDate();
        if (nowYear == birthYear) {
            returnAge = 0;//同年 则为0周岁
        }
        else {
            var ageDiff = nowYear - birthYear; //年之差
            if (ageDiff > 0) {
                if (nowMonth == birthMonth) {
                    var dayDiff = nowDay - birthDay;//日之差
                    if (dayDiff < 0) {
                        returnAge = ageDiff - 1;
                    } else {
                        returnAge = ageDiff;
                    }
                } else {
                    var monthDiff = nowMonth - birthMonth;//月之差
                    if (monthDiff < 0) {
                        returnAge = ageDiff - 1;
                    }
                    else {
                        returnAge = ageDiff;
                    }
                }
            } else {
                returnAge = -1;//返回-1 表示出生日期输入错误 晚于今天
            }
        }
        return returnAge;//返回周岁年龄
    }
}

//关闭浮窗弹出层
$(document).on('click', '.layui-m-layer .layui-msg-close', function () {
    layer.close(msglayer);
});
// =====2011.11.1 IPA end










/**
 * Update by Xu Lei on 2019.9.3
 * 批量替换
 * $('.layui-order-form #ApplicantIdType').closest('dd').find('#ApplicantIdNumber') 替换为 $('.layui-order-form #ApplicantIdType').closest('dl').find('#ApplicantIdNumber')
 * $('.layui-order-form #InsuredIdType').closest('dd').find('#InsuredIdNumber') 替换为 $('.layui-order-form #InsuredIdType').closest('dl').find('#InsuredIdNumber')
 * */

// Add by Xu Lei Start on 2019.9.3 弹窗输入框可见
//$(document).on('focus', '.layui-order-form input', function () {
//    if (!$(this).parent().hasClass('drop-item'))
//        this.scrollIntoView();
//})
// Add by Xu Lei End on 2019.9.3

//验证状态
var ordervalid;

// 倒计时 验证码倒计时使用
var wait = 60;

var isLateralNavAnimating = false;

var maxYear = $("#HidmaxOld").val();

//订单确认状态
var orderconfirm = false;

$body = (window.opera) ? (document.compatMode == "CSS1Compat" ? $('html') : $('body')) : $('html,body');
//日期
function birthdaypicker(filter) {

    (function ($, doc, $$) {
        /*  ============================================================
         *  投保人、被保人出生日期
         */
        var birthpickers = $$(filter);
        birthpickers.each(function (i, o) {
            var $this = $$(this);
            var _this = this;
            var name = _this.getAttribute('name');
            var setMinDate = 0;
            var HidmaxOld = $$("#HidmaxOld").val();
            var HidminOld = $$("#HidminOld").val();
            setMinDate = parseInt(HidmaxOld) + 1;
            o.addEventListener('click', function () {
                //日期为空时点击报错交互更新
                // $this.blur();
                var dtpicker;
                //投保人生日日期
                if (name == 'ApplicantBrithDate') {
                    dtpicker = new mui.DtPicker({
                        type: 'date',
                        buttons: ['取消', '完成'],
                        //beginDate: new Date(moment().add(-(setMinDate), 'year').add(1, 'day').format('YYYY/MM/DD')),
                        beginDate: new Date(moment().add(-(81), 'year').format('YYYY/MM/DD')),
                        endDate: new Date(moment().add(-18, 'year').format('YYYY/MM/DD')),
                        value: moment().add(-18, 'year').format('YYYY-MM-DD')
                    })
                    dtpicker.show(function (e) {
                        _this.value = e.text;
                        dtpicker.dispose();
                        $this.blur();
                    });
                }
                //被保人生日日期
                else {
                    //var t1 = moment().format('YYYY-MM-DD');
                    //var t2 = order_PolicyStartDate;
                    //var diff_days = moment(t2).diff(t1, 'days');
                    dtpicker = new mui.DtPicker({
                        type: 'date',
                        buttons: ['取消', '完成'],
                        // beginDate: new Date(moment().add(-(setMinDate), 'year').add(2, 'day').format('YYYY/MM/DD')),
                        //update by lisa 20200110 被保人出生日期控制
                        //beginDate: new Date(moment().add(-56, 'year').add(diff_days+1, 'day').format('YYYY/MM/DD')),
                        //endDate: new Date(moment().add(-18, 'year').add(diff_days-1, 'day').format('YYYY/MM/DD')),
                        //updayte by lisa  控制被保人出生日期选择范围在可选的年龄段里面 保证临界值可以取[ex：GBA 已满50未满51可以买]
                        beginDate: new Date(moment(order_PolicyStartDate).add(-(setMinDate), 'year').add(1, 'day').format('YYYY/MM/DD')),
                        endDate: new Date(moment(order_PolicyStartDate).add(-(HidminOld), 'year').format('YYYY/MM/DD')),
                         //update by lisa   绑定上次的日期到日历控件，第一次默认是最小日期
                       // value: moment().add(-1, 'year').format('YYYY-MM-DD')
                        value: $$('.layui-order-form #InsuredBrithDate').val()
                    })


                    dtpicker.show(function (e) {
                        _this.value = e.text;
                        dtpicker.dispose();
                        $this.blur();
                    });
                }
            }, false);
        });
    })(mui, document, jQuery);
}

// Add by Xu Lei Start on 2019.9.3 证件有效期
function IDperiodpicker(filter) {
    (function ($, doc, $$) {
        /*  ============================================================
         *  投保人、被保险人证件有效期
         */
        $$(filter).click(function () {
            var idpicker;
            idpicker = new mui.DtPicker({
                type: 'date',
                buttons: ['取消', '完成'],
                beginDate: new Date(moment().add(1, 'day').format('YYYY/MM/DD')),
                endDate: new Date(moment().add(30, 'year').format('YYYY/MM/DD')),
            })
            idpicker.show(function (e) {
                $$(filter).val(e.text).blur();
                idpicker.dispose();
            });
        });
    })(mui, document, jQuery);
}
// Add by Xu Lei End on 2019.9.3

//未登录隐藏历史下拉框
function HistoryOrder_Hidden() {
    $(".HistoryOrder").removeClass("HistoryOrder_Block");
    $(".HistoryOrder").addClass("HistoryOrder_Hidden");
    $(".order-page-box input[history=history]").removeClass("HistoryOrder_bg");
    $(".order-page-box input[history=history]").addClass("HistoryOrder_bg_none");
}
//登录显示历史下拉框
function HistoryOrder_block() {
    $(".HistoryOrder").removeClass("HistoryOrder_Hidden");
    $(".HistoryOrder").addClass("HistoryOrder_Block");
    $(".order-page-box input[history=history]").removeClass("HistoryOrder_bg_none");
    $(".order-page-box input[history=history]").addClass("HistoryOrder_bg");
}
//清空当前编辑弹窗的错误消息，历史下拉时候需要清空 重新选择投保关系也需要清空
function ClearApplicantErrormsg(str) {
    if (str == "Applicant") {
        $('.layui-order-form #ApplicantName').removeClass('Validform_error');
        $('.layui-order-form #ApplicantGender').removeClass('Validform_error');
        $('.layui-order-form #ApplicantBrithDate').removeClass('Validform_error');
        $('.layui-order-form #ApplicantIdType').removeClass('Validform_error');
        $('.layui-order-form #ApplicantIdNumber').removeClass('Validform_error');
        $('.layui-order-form #ApplicantMobile').removeClass('Validform_error');
        $('.layui-order-form #ApplicantEmail').removeClass('Validform_error');
        //所在地
        
        //$('.layui-order-form #ApplicantArea').removeClass('Validform_error');
        // add by qufeng 2023/11/21 所在地 start
        $('.layui-order-form #ApplicantLiveCity').removeClass('Validform_error');
        $('.layui-order-form ApplicantLiveAddress').removeClass('Validform_error');
           // add by qufeng 2023/11/21 所在地 end
        // Add by Xu Lei Start on 2019.9.3
        $('.layui-order-form input').removeClass('Validform_error Validform_error2');
        // Add by Xu Lei End on 2019.9.3
    }
    else {
        $('.layui-order-form #InsuredName').removeClass('Validform_error');
        $('.layui-order-form #InsuredGender').removeClass('Validform_error');
        $('.layui-order-form #InsuredBrithDate').removeClass('Validform_error');
        $('.layui-order-form #InsuredIdType').removeClass('Validform_error');
        $('.layui-order-form #InsuredIdNumber').removeClass('Validform_error');
        $('.layui-order-form #InsuredMobile').removeClass('Validform_error');
        // add by qufeng 2023/11/21 所在地 start
        $('.layui-order-form #InsuredLiveCity').removeClass('Validform_error');
        $('.layui-order-form #InsuredLiveAddress').removeClass('Validform_error');
         // add by qufeng 2023/11/21 所在地 end
        $(".layui-order-form .step-form .tip-relation").hide();
        $(".layui-order-form .step-form .tip-repeatinsured").hide();
        // Add by Xu Lei Start on 2019.9.3
        $('.layui-order-form input').removeClass('Validform_error Validform_error2');
        // Add by Xu Lei End on 2019.9.3
    }

}

//投保人资料更改后不能和被保人重复
function checkApplicantDuplicate() {
    //有被保人
    if ($('#step-insured .step-info-box .step-info').length > 0) {
        //update by Eren js升级的代码 20190419 start
        //var CurrentApplicantIDno = $('.layui-order-form #ApplicantIdNumber').val().toLowerCase();
        var CurrentApplicantIDno = $('.layui-order-form input[id=ApplicantIdNumber]').val();
        var CurrentApplicantIdcard = $('.layui-order-form input[id=ApplicantIdCard ]').val();
        var currentIdType = $('.layui-order-form input[name=ApplicantIdType]').val();

        //update by Eren js升级的代码 20190419 end
        $('#step-insured .step-info-box .step-info').each(function (ind) {
            var currform = $(this);
            var otherRelation = currform.find('input[custype=insured_relation]').val();
            var otherIDNo = currform.find('input[custype=insured_idno]').val();
            var otherIDCard = currform.find('input[custype=insured_idcard]').val();
            var otherType = currform.find('input[custype=insured_idtype]').val();

            if (otherRelation != "本人") {
                if (!checkDuplicateCore(currentIdType, CurrentApplicantIDno, CurrentApplicantIdcard, otherType, otherIDNo, otherIDCard)) {
                    $('.layui-order-form #ApplicantName').addClass('Validform_error').removeClass('Validform_error2').val('与被保险人信息重复，请更正');
                    return false;
                }
            }
        });
    }
}

/** 证件类型非身份证，身份证字段验证重复**/
function checkApplicantIdcardDuplicate() {
    //有被保人
    if ($('#step-insured .step-info-box .step-info').length > 0) {
        var CurrentApplicantIDcard = $('.layui-order-form #ApplicantIdType').closest('.step-form').find('#ApplicantIdCard').val().trim().toLowerCase();
        $('#step-insured .step-info-box .step-info').each(function () {
            var thisRelation = $(this).find('input[custype=insured_relation]').val();
            if (thisRelation != "本人") {
                var thisInsuredIDno = $(this).find('input[custype=insured_idno]').val();
                var thisInsuredIDcard = $(this).find('input[custype=insured_idcard]').val();
                if (thisInsuredIDno.toLowerCase().trim() == CurrentApplicantIDcard) {
                    $('.layui-order-form #ApplicantName').addClass('Validform_error').removeClass('Validform_error2').val('被保险人信息不能重复，请更正');
                    return false;
                }
                if (thisInsuredIDcard != '') {
                    if (thisInsuredIDcard.toLowerCase().trim() == CurrentApplicantIDcard) {
                        $('.layui-order-form #ApplicantName').addClass('Validform_error').removeClass('Validform_error2').val('被保险人信息不能重复，请更正');
                        alert('被保险人信息不能重复，请更正');
                        return false;
                    }
                }
            }
        });
    }
}

//检验被保人是否重复 
function checkInsuredDuplicate($thisindex) {

    var currInsured = $('.layui-order-form #InsuredRelation').closest('.step-form');
    var CurrentInsuredIDNo = currInsured.find('#InsuredIdNumber').val().toLowerCase().trim();

    //var CurrentInsuredIDNo = $('.layui-order-form #InsuredIdNumber').val().toLowerCase().trim();
    var CurrentApplicantIDno = $("#step-applicant .step-info #ApplicantIdNumber").val().toLowerCase().trim();

    var CurrentInsuredRelation = $('.layui-order-form #InsuredRelation').val();
    var CurrentInsuredCount = $('#step-insured .step-info-box .step-info').length;

    //insured info
    var insuredIdtype = currInsured.find('input[custype=insured_idtype]').val();
    var insuredId = currInsured.find('input[custype=insured_idno]').val().toUpperCase();
    var insuredNum = currInsured.find('input[custype="insured_idcard"]').val().toUpperCase();
    var callback = function () {
        if ($(".layui-order-form .step-form").find(".tip-repeatinsured").is(":hidden")) {
            $(".layui-order-form .step-form .tip-repeatinsured").show();
        }
    };
    //如果被保人没有本人，证件号码一致 需要提示选择投保人关系
    if (!($('#insured-oneself').length > 0) && CurrentInsuredRelation != "本人") {
        //applicant info
        var applicantId = CurrentApplicantIDno.toUpperCase();
        var applicantNum = $("#step-applicant .step-info input[name=ApplicantIdCard]").val().toUpperCase();
        var applicantidtype = $("#step-applicant .step-info input[name=ApplicantIdType]").val();

        var currIdType = insuredIdtype;
        var currIdno = insuredId;
        var currIdcardNo = insuredNum;

        var relationCallback = function () {
            if ($(".layui-order-form .step-form").find(".tip-relation").is(":hidden")) {
                $(".layui-order-form .step-form .tip-relation").show();
            }
            return false;
        };

        if (!checkDuplicateCore(currIdType, currIdno, currIdcardNo, applicantidtype, applicantId, applicantNum, relationCallback)) {
            return false;
        }
    }
    //编辑
    if ($("#editstatus").val() == "true") {
        //当前编辑人的序号
        var editIndex = $("#editstatus").attr("name");
        $('#step-insured .step-info-box .step-info input[custype=insured_idno]').each(function (ind) {
            var thisindex = $(this).parents("#step-insured .step-info-box .step-info").index();
            //校验被保人本人
            //排除正在编辑同一人资料
            if (thisindex != editIndex) {
                var that = $(this).parents('.step-info');
                var currIdType = insuredIdtype;
                var currIdno = insuredId;
                var currIdcardNo = insuredNum;
                var otherType = that.find('input[custype="insured_idtype"]').val();
                var otherIdNo = that.find('input[custype="insured_idno"]').val();
                var otherIdcardNo = that.find('input[custype="insured_idcard"]').val();

                if (!checkDuplicateCore(currIdType, currIdno, currIdcardNo, otherType, otherIdNo, otherIdcardNo, callback)) {
                    return false;
                }
            }
            else {
                if (CurrentInsuredRelation != "本人") {
                    var applicantId = CurrentApplicantIDno.toUpperCase();
                    var applicantNum = $("#step-applicant .step-info input[name=ApplicantIdCard]").val().toUpperCase();
                    var applicantidtype = $("#step-applicant .step-info input[name=ApplicantIdType]").val();

                    var currIdType = insuredIdtype;
                    var currIdno = insuredId;
                    var currIdcardNo = insuredNum;

                    var relationCallback = function () {
                        if ($(".layui-order-form .step-form").find(".tip-relation").is(":hidden")) {
                            $(".layui-order-form .step-form .tip-relation").show();
                        }
                        return false;
                    };

                    if (!checkDuplicateCore(currIdType, currIdno, currIdcardNo, applicantidtype, applicantId, applicantNum, relationCallback)) {
                        return false;
                    }
                }
            }
        });
    }

    //非编辑
    if ($("#editstatus").val() == "false") {
        //检验被保人之间是否重复
        if (CurrentInsuredCount > 0) {

            $('#step-insured .step-info-box .step-info input[custype=insured_idno]').each(function (ind) {
                var that = $(this).parents('.step-info');
                var currIdType = insuredIdtype;
                var currIdno = insuredId;
                var currIdcardNo = insuredNum;
                var otherType = that.find('input[custype="insured_idtype"]').val();
                var otherIdNo = that.find('input[custype="insured_idno"]').val();
                var otherIdcardNo = that.find('input[custype="insured_idcard"]').val();

                if (!checkDuplicateCore(currIdType, currIdno, currIdcardNo, otherType, otherIdNo, otherIdcardNo, callback)) {
                    return false;
                }
            });
        }
    }
};


//check duplicated of other people
function checkDuplicateCore(currIdType, currIdno, currIdcardNo, otherType, otherIdNo, otherIdcardNo, callback) {
    //misalignment issue
    otherIdcardNo = otherType == '身份证' ? otherIdNo : otherIdcardNo;
    currIdcardNo = currIdType == '身份证' ? currIdno : currIdcardNo;

    //first check id card duplicate
    if (otherIdcardNo == currIdcardNo && otherIdcardNo) {
        if (callback) callback();

        return false;
    }
    //then check (idno and idtype) are same and they are not empty
    if (currIdno == otherIdNo && currIdno) {
        if (callback) callback();
        return false;
    }
    return true;
}


//投保人信息更改后同步更改被保人中本人的信息
function UpdateInsuredforOwn() {

    if ($('#insured-oneself').length > 0) {
        //更新资料
        var i = $('#insured-oneself').index();
        var ApplicantName = $('.layui-order-form #ApplicantName').val();
        var ApplicantMobile = $('.layui-order-form #ApplicantMobile').val();
        var ApplicantBrithDate = $('.layui-order-form #ApplicantBrithDate').val();
        //update by Eren js升级的代码 20190419 start
        //var ApplicantIdNumber = $('.layui-order-form #ApplicantIdNumber').val();
        var ApplicantIdNumber = $('.layui-order-form #ApplicantIdType').closest('dl').find('#ApplicantIdNumber').val().trim();
        //update by Eren js升级的代码 20190419 end
        var ApplicantIdType = $('.layui-order-form #ApplicantIdType').val();
        var ApplicantGender = $('.layui-order-form #ApplicantGender').val();

        // Add by Xu Lei Start on 2019.9.3
        var ApplicantNationality = $('.layui-order-form #ApplicantNationality').val();
        var ApplicantIdNoPeriod = $('.layui-order-form #ApplicantIdNoPeriod').val();
        //var ApplicantIdCard = $('.layui-order-form #ApplicantIdCard').val();
        var ApplicantIdCard = $('.layui-order-form input[id=ApplicantIdCard]').val();//update by eren 20191009 微信端找不到对象
        var ApplicantIdCardPeriod = $('.layui-order-form #ApplicantIdCardPeriod').val();
        var ApplicantLiveCity = $('.layui-order-form #ApplicantLiveCity').val();
        var ApplicantLiveAddress = $('.layui-order-form #ApplicantLiveAddress').val();
        //var ApplicantJobCompany = $('.layui-order-form #ApplicantJobCompany').val();
        var ApplicantJobCompany = $('.layui-order-form input[id=ApplicantJobCompany]').val();//update by eren 20191030 微信端直接通过id找不到对象
        var ApplicantJobCareer = $('.layui-order-form #ApplicantJobCareer').val();
        var ApplicantJobIncome = $('.layui-order-form #ApplicantJobIncome').val();
        // Add by Xu Lei End on 2019.9.3

        $("#insured-oneself #InsuredPersons_" + i + "__NAME").val(ApplicantName);
        $("#insured-oneself #InsuredPersons_" + i + "__MOBILE").val(ApplicantMobile);
        $("#insured-oneself #InsuredPersons_" + i + "__BIRTH_DATE").val(ApplicantBrithDate);
        $("#insured-oneself #InsuredPersons_" + i + "__ID_NO").val(ApplicantIdNumber);
        $("#insured-oneself #InsuredPersons_" + i + "__ID_TYPE_ID").val(ApplicantIdType);
        $("#insured-oneself #InsuredPersons_" + i + "__GENDER").val(ApplicantGender);

        // Add by Xu Lei Start on 2019.9.3 新增字段
        $("#insured-oneself #InsuredPersons_" + i + "__NATIONALITY").val(ApplicantNationality);
        $("#insured-oneself #InsuredPersons_" + i + "__ID_NO_PERIOD").val(ApplicantIdNoPeriod);
        $("#insured-oneself #InsuredPersons_" + i + "__ID_CARD").val(ApplicantIdCard);
        $("#insured-oneself #InsuredPersons_" + i + "__ID_CARD_PERIOD").val(ApplicantIdCardPeriod);
        $("#insured-oneself #InsuredPersons_" + i + "__LIVE_CITY").val(ApplicantLiveCity);
        $("#insured-oneself #InsuredPersons_" + i + "__LIVE_ADDRESS").val(ApplicantLiveAddress);
        $("#insured-oneself #InsuredPersons_" + i + "__JOB_COMPANY").val(ApplicantJobCompany);
        $("#insured-oneself #InsuredPersons_" + i + "__JOB_CAREER").val(ApplicantJobCareer);
        $("#insured-oneself #InsuredPersons_" + i + "__JOB_INCOME").val(ApplicantJobIncome);
        // Add by Xu Lei End on 2019.9.3

        //更新全局变量
        aig_orderStorage.insured[i] = {
            'name': ApplicantName,
            'sex': ApplicantGender,
            'birthday': ApplicantBrithDate,
            'idtype': ApplicantIdType,
            'idno': ApplicantIdNumber,
            'mobile': ApplicantMobile,
            'relation': "本人",

            // Add by Xu Lei Start on 2019.9.3
            'nationality': $('.layui-order-form #ApplicantNationality').val(),
            'idnoperiod': $('.layui-order-form #ApplicantIdNoPeriod').val(),
            //'idcard': $('.layui-order-form #ApplicantIdCard').val(),
            'idcard': $('.layui-order-form input[id=ApplicantIdCard]').val(),//update by eren 20191007 微信端直接通过id找不到对象
            'idcardperiod': $('.layui-order-form #ApplicantIdCardPeriod').val(),
            'livecity': $('.layui-order-form #ApplicantLiveCity').val(),
            'liveaddress': $('.layui-order-form #ApplicantLiveAddress').val(),
            //'jobcompany': $('.layui-order-form #ApplicantJobCompany').val(),
            'jobcompany': $('.layui-order-form input[id=ApplicantJobCompany]').val(),//update by eren 20191030 微信端直接通过id找不到对象
            'jobcareer': $('.layui-order-form #ApplicantJobCareer').val(),
            'jobincome': $('.layui-order-form #ApplicantJobIncome').val()
            // Add by Xu Lei End on 2019.9.3
        };



        //性别转化
        var tempsex = ApplicantGender == "True" ? "男" : "女";
        // Update by Xu Lei Start on 2019.9.3
        var isshow_idcard = 1;
        if ((aig_orderStorage.insured[i].nationality == '中国' && aig_orderStorage.insured[i].idtype == '身份证') || aig_orderStorage.insured[i].nationality != '中国') {
            isshow_idcard = 0;
        }
        var inncomme = aig_orderStorage.applicant.jobincome;
        if (inncomme.indexOf('以上') > 0) {
            inncomme = '50万以上/年';
        } else if (inncomme) {
            inncomme += '万/年';
        }
        //Update by Xu Lei at 2020.10.30 for 添加百万医疗DTC Start
        //update by lisa 202020108 GBA 只有一个被保人，隐藏删除被保人按钮
        var IsShowDelBtbHtml = "";
        var ProductCode = $("input[name='ProductCode']").val();
        // Update 2021.01.05 for 更新一生康美DTC Start
        // if (ProductCode == "150331" || ProductCode == "180301" || ProductCode == "18030101") {
        //     IsShowDelBtbHtml = 'style = "display:none !important;margin:1.25rem auto;';
        // }
        if (ProductCode == "150331" || ProductCode == "18030101") {
            IsShowDelBtbHtml = 'style = "display:none !important;margin:1.25rem auto;';
        }
        // Update 2021.01.05 for 更新一生康美DTC End
        //Update by Xu Lei at 2020.10.30 for 添加百万医疗DTC End
        //Update by Xu Lei at 2020.11.03 for 添加百万医疗DTC Start
        if ($("input[name='ProductCode']").val() == '180301' || $("input[name='ProductCode']").val() == '180302' || $("input[name='ProductCode']").val() == '18030101') {
            // Update 2022.01.05 for 一生康美 Start
            var temphtml = '' +
                '<ul>\n' +
                '<li class="name">' + aig_orderStorage.insured[i].name + '<input value="' + aig_orderStorage.insured[i].relation + '" name="InsuredPersons[' + i + '].RELATION_CODE" type="hidden" disabled="disabled"><input value="' + aig_orderStorage.insured[i].name + '" name="InsuredPersons[' + i + '].NAME" type="hidden" disabled="disabled" >&nbsp;<label class="relation"><em>' + aig_orderStorage.insured[i].relation + '</em></label></li>\n' +
                '<li><label>性别：</label>' + tempsex + '<input value="' + aig_orderStorage.insured[i].sex + '" name="InsuredPersons[' + i + '].GENDER" type="hidden" disabled="disabled"></li>\n' +
                '<li><label>国籍（地区）：</label>' + aig_orderStorage.insured[i].nationality + '<input value="' + aig_orderStorage.insured[i].nationality + '" name="InsuredPersons[' + i + '].NATIONALITY" type="hidden" disabled="disabled"></li>\n' +
                '<li><label>出生日期：</label>' + aig_orderStorage.insured[i].birthday + '<input value="' + aig_orderStorage.insured[i].birthday + '" name="InsuredPersons[' + i + '].BIRTH_DATE"  type="hidden" disabled="disabled"> </li>\n' +
                '<li><label>身份证：</label>' + '<label style="display:none;">' + aig_orderStorage.insured[i].idtype + '</label>' + aig_orderStorage.insured[i].idno + '<input value="' + aig_orderStorage.insured[i].idtype + '" name="InsuredPersons[' + i + '].ID_TYPE_ID" type="hidden" disabled="disabled">  <input value="' + aig_orderStorage.insured[i].idno + '" name="InsuredPersons[' + i + '].ID_NO" type="hidden" disabled="disabled"></li>\n' +
                '<li style="' + (!aig_orderStorage.insured[i].idnoperiod.length ? 'display:none' : '') + '"><label>身份证有效期至：</label>' + aig_orderStorage.insured[i].idnoperiod + '<input value="' + aig_orderStorage.insured[i].idnoperiod + '" name="InsuredPersons[' + i + '].ID_NO_PERIOD" type="hidden" disabled="disabled">\n' +
                '<li style="' + (!isshow_idcard ? 'display:none' : '') + '"><label>身份证：</label>' + aig_orderStorage.insured[i].idcard + '<input value="' + aig_orderStorage.insured[i].idcard + '" name="InsuredPersons[' + i + '].ID_CARD" type="hidden" disabled="disabled">\n' +
                '<li style="' + (!isshow_idcard || !aig_orderStorage.insured[i].idcardperiod.length ? 'display:none' : '') + '"><label>身份证有效期至：</label>' + aig_orderStorage.insured[i].idcardperiod + '<input value="' + aig_orderStorage.insured[i].idcardperiod + '" name="InsuredPersons[' + i + '].ID_CARD_PERIOD" type="hidden" disabled="disabled">\n' +
                '<li><label>手机号码：</label>' + aig_orderStorage.insured[i].mobile + '<input value="' + aig_orderStorage.insured[i].mobile + '" name="InsuredPersons[' + i + '].MOBILE" type="hidden" disabled="disabled"></li>\n' +
                // update by meixuan 2023.10.20
                '<li style="' + (!aig_orderStorage.insured[i].livecity.length ? 'display:none' : '') + '" class="address"><label>所在地：</label><span>' + aig_orderStorage.insured[i].livecity + '</span><input value="' + aig_orderStorage.insured[i].livecity + '" name="InsuredPersons[' + i + '].LIVE_CITY" type="hidden" disabled="disabled"></li>\n' +
                //'<li style="' + (!aig_orderStorage.insured[i].livecity.length ? 'display:none' : '') + '"><label>居住地址：</label>' + aig_orderStorage.insured[i].livecity + '<input value="' + aig_orderStorage.insured[i].livecity + '" name="InsuredPersons[' + i + '].LIVE_CITY" type="hidden" disabled="disabled"></li>\n' +
                '<li style="' + (!aig_orderStorage.insured[i].liveaddress.length ? 'display:none' : '') + '" class="address"><label>详细地址：</label><span>' + aig_orderStorage.insured[i].liveaddress + '</span><input value="' + aig_orderStorage.insured[i].liveaddress + '" name="InsuredPersons[' + i + '].LIVE_ADDRESS" type="hidden" disabled="disabled"></li>\n' +
                //'<li class="address" style="' + (!aig_orderStorage.insured[i].jobcompany.length ? 'display:none' : '') + '"><label>工作单位：</label><span>' + aig_orderStorage.insured[i].jobcompany + '</span><input value="' + aig_orderStorage.insured[i].jobcompany + '" name="InsuredPersons[' + i + '].JOB_COMPANY" type="hidden" disabled="disabled"></li>\n' +
                '<li style="' + (!aig_orderStorage.insured[i].jobcareer.length ? 'display:none' : '') + '"><label>职业与类别：</label>' + aig_orderStorage.insured[i].jobcareer + '<input value="' + aig_orderStorage.insured[i].jobcareer + '" name="InsuredPersons[' + i + '].JOB_CAREER" type="hidden" disabled="disabled"></li>\n' +
                '<li class="address" style="' + (!aig_orderStorage.insured[i].jobcompany.length ? 'display:none' : '') + '"><label>工作单位名称：</label><span>' + aig_orderStorage.insured[i].jobcompany + '</span><input value="' + aig_orderStorage.insured[i].jobcompany + '" name="InsuredPersons[' + i + '].JOB_COMPANY" type="hidden" disabled="disabled"></li>\n' +
                '<li style="' + (!aig_orderStorage.insured[i].jobincome.length ? 'display:none' : '') + '"><label>收入：</label>' + inncomme + '<input value="' + aig_orderStorage.insured[i].jobincome + '" name="InsuredPersons[' + i + '].JOB_INCOME" type="hidden" disabled="disabled"></li>\n' +
                '</ul>\n' +
                '<div class="btn-box"><a href="javascript:;" class="btn btn-add-insured-del" ' + IsShowDelBtbHtml + ' currentIndex="' + i + '" data-name="' + aig_orderStorage.insured[i].name + '">删除</a><a href="javascript:;" class="btn btn-add-insured-edit">修改</a></div>\n' +
                '</div>';
                // Update 2022.01.05 for 一生康美 End
        } else {
            var temphtml = '' +
                '<ul>\n' +
                '<li><label>与投保人关系：</label>本人<input value="本人" name="InsuredPersons[' + i + '].RELATION_CODE" type="hidden" disabled="disabled"></li>\n' +
                '<li><label>被保险人姓名：</label>' + aig_orderStorage.insured[i].name + '<input value="' + aig_orderStorage.insured[i].name + '" name="InsuredPersons[' + i + '].NAME" type="hidden" disabled="disabled" ></li>\n' +
                '<li><label>性别：</label>' + tempsex + '<input value="' + aig_orderStorage.insured[i].sex + '" name="InsuredPersons[' + i + '].GENDER" type="hidden" disabled="disabled"></li>\n' +
                '<li><label>国籍（地区）：</label>' + aig_orderStorage.insured[i].nationality + '<input value="' + aig_orderStorage.insured[i].nationality + '" name="InsuredPersons[' + i + '].NATIONALITY" type="hidden" disabled="disabled"></li>\n' +
                '<li><label>出生日期：</label>' + aig_orderStorage.insured[i].birthday + '<input value="' + aig_orderStorage.insured[i].birthday + '" name="InsuredPersons[' + i + '].BIRTH_DATE"  type="hidden" disabled="disabled"> </li>\n' +
                '<li><label>证件信息：</label>' + aig_orderStorage.insured[i].idtype + '-' + aig_orderStorage.insured[i].idno + '<input value="' + aig_orderStorage.insured[i].idtype + '" name="InsuredPersons[' + i + '].ID_TYPE_ID" type="hidden" disabled="disabled">  <input value="' + aig_orderStorage.insured[i].idno + '" name="InsuredPersons[' + i + '].ID_NO" type="hidden" disabled="disabled"></li>\n' +
                '<li style="' + (!aig_orderStorage.insured[i].idnoperiod.length ? 'display:none' : '') + '"><label>证件有效期至：</label>' + aig_orderStorage.insured[i].idnoperiod + '<input value="' + aig_orderStorage.insured[i].idnoperiod + '" name="InsuredPersons[' + i + '].ID_NO_PERIOD" type="hidden" disabled="disabled">\n' +
                '<li style="' + (!isshow_idcard ? 'display:none' : '') + '"><label>身份证：</label>' + aig_orderStorage.insured[i].idcard + '<input value="' + aig_orderStorage.insured[i].idcard + '" name="InsuredPersons[' + i + '].ID_CARD" type="hidden" disabled="disabled">\n' +
                '<li style="' + (!isshow_idcard || !aig_orderStorage.insured[i].idcardperiod.length ? 'display:none' : '') + '"><label>身份证有效期至：</label>' + aig_orderStorage.insured[i].idcardperiod + '<input value="' + aig_orderStorage.insured[i].idcardperiod + '" name="InsuredPersons[' + i + '].ID_CARD_PERIOD" type="hidden" disabled="disabled">\n' +
                '<li><label>手机号码：</label>' + aig_orderStorage.insured[i].mobile + '<input value="' + aig_orderStorage.insured[i].mobile + '" name="InsuredPersons[' + i + '].MOBILE" type="hidden" disabled="disabled"></li>\n' +
                // update by meixuan 2023.10.20
                '<li style="' + (!aig_orderStorage.insured[i].livecity.length ? 'display:none' : '') + '" class="address"><label>所在地：</label><span>' + aig_orderStorage.insured[i].livecity + '</span><input value="' + aig_orderStorage.insured[i].livecity + '" name="InsuredPersons[' + i + '].LIVE_CITY" type="hidden" disabled="disabled"></li>\n' +
                //'<li style="' + (!aig_orderStorage.insured[i].livecity.length ? 'display:none' : '') + '"><label>居住地址：</label>' + aig_orderStorage.insured[i].livecity + '<input value="' + aig_orderStorage.insured[i].livecity + '" name="InsuredPersons[' + i + '].LIVE_CITY" type="hidden" disabled="disabled"></li>\n' +
                '<li style="' + (!aig_orderStorage.insured[i].liveaddress.length ? 'display:none' : '') + '" class="address"><label>详细地址：</label><span>' + aig_orderStorage.insured[i].liveaddress + '</span><input value="' + aig_orderStorage.insured[i].liveaddress + '" name="InsuredPersons[' + i + '].LIVE_ADDRESS" type="hidden" disabled="disabled"></li>\n' +
                //'<li class="address" style="' + (!aig_orderStorage.insured[i].jobcompany.length ? 'display:none' : '') + '"><label>工作单位：</label><span>' + aig_orderStorage.insured[i].jobcompany + '</span><input value="' + aig_orderStorage.insured[i].jobcompany + '" name="InsuredPersons[' + i + '].JOB_COMPANY" type="hidden" disabled="disabled"></li>\n' +
                '<li style="' + (!aig_orderStorage.insured[i].jobcareer.length ? 'display:none' : '') + '"><label>职业与类别：</label>' + aig_orderStorage.insured[i].jobcareer + '<input value="' + aig_orderStorage.insured[i].jobcareer + '" name="InsuredPersons[' + i + '].JOB_CAREER" type="hidden" disabled="disabled"></li>\n' +
                '<li class="address" style="' + (!aig_orderStorage.insured[i].jobcompany.length ? 'display:none' : '') + '"><label>工作单位名称：</label><span>' + aig_orderStorage.insured[i].jobcompany + '</span><input value="' + aig_orderStorage.insured[i].jobcompany + '" name="InsuredPersons[' + i + '].JOB_COMPANY" type="hidden" disabled="disabled"></li>\n' +
                '<li style="' + (!aig_orderStorage.insured[i].jobincome.length ? 'display:none' : '') + '"><label>收入：</label>' + inncomme + '<input value="' + aig_orderStorage.insured[i].jobincome + '" name="InsuredPersons[' + i + '].JOB_INCOME" type="hidden" disabled="disabled"></li>\n' +
                '</ul>\n' +
                '<div class="btn-box"><a href="javascript:;" class="btn btn-add-insured-del" ' + IsShowDelBtbHtml + ' currentIndex="' + i + '" data-name="' + aig_orderStorage.insured[i].name + '">删除</a><a href="javascript:;" class="btn btn-add-insured-edit">修改</a></div>\n' +
                '</div>';
        }
        //Update by Xu Lei at 2020.11.03 for 添加百万医疗DTC End
        $('#insured-oneself').html(temphtml);
        // Update By Xu Lei End on 2019.9.3
    }
}

//下拉框选择不同证件类型控制性别控件 出生日期控件禁用与否
function disabledSexAndBirthday($boxscroll, v) {
    var isWrong = $boxscroll.hasClass("Validform_error");
    if (isWrong) {
        return true;
    }
    var isWrong = $boxscroll.hasClass("Validform_error2");
    if (isWrong) {
        return true;
    }
    if (v == '身份证') {
        $boxscroll.parents('dl').siblings('dl').find('.radio').addClass('disabled');
        //投保人
        if ($boxscroll.parents(".step-form").attr("section") == "applicantstep") {
            $boxscroll.parents(".step-form").find("input[name=ApplicantBrithDate]").attr("disabled", true);
        }
        //被保人
        else {
            $boxscroll.parents(".step-form").find("input[name=InsuredBrithDate]").attr("disabled", true);
        }
    }
    //非身份证
    else {
        //被保人为本人时候不启用出生日期和性别
        if ($boxscroll.parents(".step-form").attr("section") == "applicantstep") {
            $boxscroll.parents('dl').siblings('dl').find('.radio').removeClass('disabled');
            $boxscroll.parents(".step-form").find("input[name=ApplicantBrithDate]").attr("disabled", false);
        }
        else {
            if ($boxscroll.parents(".step-form").find("input[name=InsuredRelation]").val() != "本人") {
                $boxscroll.parents('dl').siblings('dl').find('.radio').removeClass('disabled');
                $boxscroll.parents(".step-form").find("input[name=InsuredBrithDate]").attr("disabled", false);
            }
        }
    }
    UpdateDataTypeForIDno($boxscroll, v)
}

// 身份证填写完后自动更新 性别，出生日期
function UpdateSexandBirthdayByIDNo($boxscroll, v) {
    var isWrong = $boxscroll.hasClass("Validform_error");
    if (isWrong) {
        return true;
    }
    if (v == '身份证') {

        //to do
        var UUserCard = $boxscroll.val();
        //check IDno rule
        var birthdate;
        var sex;
        if (UUserCard.length == 18) {
            birthdate = UUserCard.substring(6, 10);
            birthdate = birthdate + "-" + UUserCard.substring(10, 12) + "-" + UUserCard.substring(12, 14);
            sex = parseInt(UUserCard.substr(16, 1)) % 2 == 1;

        }
        else {
            birthdate = UUserCard.substring(6, 8);
            if (birthdate > 20) {
                birthdate = "19" + birthdate;
            }
            else {
                birthdate = "20" + birthdate;
            }

            birthdate = birthdate + "-" + UUserCard.substring(8, 10) + "-" + UUserCard.substring(10, 12);
            sex = parseInt(UUserCard.substr(14, 1)) % 2 == 1;
        }

        // 性别为男提示请正确填写被保险人信息
        if($boxscroll.parents(".step-form").attr("section") =='insuredstep'&&sex == true){
            layer.open({
                className: 'mxui-alert'
                , content: '<i class="icon icon-warn">&nbsp;</i>请正确填写被保险人信息'
                , skin: 'msg'
                , time: 2
            });
            $boxscroll.parents(".step-form").find("input[name=InsuredBrithDate]").val('');
            $boxscroll.parents(".step-form").find("input[name=InsuredGender]").val('');
            return false;
        }

        //sex
        $boxscroll.parents(".step-form").find(".v2-radio-box ul li a").removeClass('selected') & $('.layui-order-form .step-form .v2-radio-box ul li:eq(' + (sex == true ? 0 : 1) + ') a').addClass('selected');
        sexvalue = sex == true ? "True" : "False";
        //birthday
        //投保人
        if ($boxscroll.parents(".step-form").attr("section") == "applicantstep") {

            //update by eren 20190929 证件号校验不通过将出生日期输入框内容置空 start
            var reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
            if (reg.test(UUserCard) === false) {
                birthdate = "";
            }
            else {
                $boxscroll.parents(".step-form").find("input[name=ApplicantBrithDate]").removeClass('Validform_error');
            }
            //update by eren 20190929 证件号校验不通过将出生日期输入框内容置空 end           
            $boxscroll.parents(".step-form").find("input[name=ApplicantBrithDate]").val(birthdate);
            $boxscroll.parents(".step-form").find("input[name=ApplicantGender]").val(sexvalue);
        }
        //被保人
        else {
            //update by eren 20190929 证件号校验不通过将出生日期输入框内容置空 start
            var reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
            if (reg.test(UUserCard) === false) {
                birthdate = "";
            }
            else {
                $boxscroll.parents(".step-form").find("input[name=InsuredBrithDate]").removeClass('Validform_error');
            }
            //update by eren 20190929 证件号校验不通过将出生日期输入框内容置空 end          
            $boxscroll.parents(".step-form").find("input[name=InsuredBrithDate]").val(birthdate);
            $boxscroll.parents(".step-form").find("input[name=InsuredGender]").val(sexvalue);
        }
    } else if (v == '外国人永久居留身份证') {
        var idinfo = $.foreignerIdcardCheck($boxscroll.val());

        if (idinfo.isTure) {
            //sex
            $boxscroll.parents(".step-form").find(".v2-radio-box ul li a").removeClass('selected') & $('.layui-order-form .step-form .v2-radio-box ul li:eq(' + (sex == true ? 0 : 1) + ') a').addClass('selected');
            sexvalue = idinfo.sex == true ? "True" : "False";

            //birthday
            //投保人
            if ($boxscroll.parents(".step-form").attr("section") == "applicantstep") {
                $boxscroll.parents(".step-form").find("input[name=ApplicantBrithDate]").removeClass('Validform_error');
                $boxscroll.parents(".step-form").find("input[name=ApplicantBrithDate]").val(idinfo.birthdate);
                $boxscroll.parents(".step-form").find("input[name=ApplicantGender]").val(sexvalue);
            }
            //被保人
            else {
                $boxscroll.parents(".step-form").find("input[name=InsuredBrithDate]").removeClass('Validform_error');
                $boxscroll.parents(".step-form").find("input[name=InsuredBrithDate]").val(idinfo.birthdate);
                $boxscroll.parents(".step-form").find("input[name=InsuredGender]").val(sexvalue);
            }
        } else {
            //update by eren 20190929 证件号校验不通过将出生日期输入框内容置空 start
            //投保人
            if ($boxscroll.parents(".step-form").attr("section") == "applicantstep") {
                $boxscroll.parents(".step-form").find("input[name=ApplicantBrithDate]").val("");
            } else {
                $boxscroll.parents(".step-form").find("input[name=InsuredBrithDate]").val("");
            }

            $boxscroll.val('请正确填写证件号').addClass("Validform_error").removeClass("Validform_error2");
        }
    }
}

//身份证的联动 选择身份证证件类型后更改证件号码
function UpdateDataTypeForIDno($boxscroll, v) {
    var isWrong = $boxscroll.hasClass("Validform_error");
    if (isWrong) {
        return true;
    }
    // Update by Xu Lei Start on 2019.9.3 显示身份证字段信息
    var datatype = "no";
    if (v == '身份证') {
        datatype = "idcard";
        $('.layui-order-form .idcard-info').hide(),
            $('.layui-order-form .idcard-info input').val('').removeClass('Validform_error').attr('ignore', 'ignore'),
            $('.layui-order-form .idcard-info input[rel=idcardperiodcheck]').val('False').closest('dd').find('a.checkbox').removeClass('selected');
    } else {
        if ($('.layui-order-form input[rel=nationality]').val() == '中国') {
            $('.layui-order-form .idcard-info').show();
            IDperiodpicker('.layui-order-form input[rel=idcardperiod]');
        }
    }
    // Update by Xu Lei End on 2019.9.3
    //投保人
    if ($boxscroll.parents(".step-form").attr("section") == "applicantstep") {
        $boxscroll.parents(".step-form").find("input[name=ApplicantIdNumber]").attr("datatype", datatype);
    }
    //被保人
    else {
        $boxscroll.parents(".step-form").find("input[name=InsuredIdNumber]").attr("datatype", datatype);
    }
    //ordervalid.addRule([
    //           {
    //               ele: $boxscroll.parents(".step-form").find(".item-control  input[rel=idno]"),
    //               datatype: datatype
    //           }
    //]);

}

// Add by Xu Lei Start on 2019.9.3 
//国籍选择窗口显示
var layer_country;
$(document).on('click', '.layui-order-form input[rel=nationality]', function () {
    $(this).blur();
    layer_country = layer.open({
        type: 1
        , shade: 0
        , content: '<div class="countryBox" id="divCountryWindow">' + $('#tpl-nationality .countryBox').html() + '</div>'
        , anim: 'up'
        , style: 'position:fixed; left:0; top:0; width:100%; height:100%; border: none; -webkit-animation-duration: .3s; animation-duration: .3s;'
    });
});
//国籍所属洲切换
$(document).on('click', '#divCountryWindow>.country-tab>ul>li>a', function () {
    var i = $(this).parent().index();
    $(this).addClass('on').parent().siblings().find('a').removeClass('on');
    $('#divCountryWindow.countryBox .country-cont .cont:eq(' + i + ')').show().siblings().hide();
})
//国籍点击选择
$(document).on('click', '#divCountryWindow>.country-cont>div>dl>dd>a', function () {
    var $this = $(this);
    // 国家变更，获取国家对应产品信息ProductCode、最低报价计划、产品保障天数
    if ($this.text()) {
        $(".layui-order-form input[rel=nationality]").val($this.text()).blur();
        //清空证件信息
        var $parent = $('.layui-order-form .step-form');
        $parent.find('input[rel=idtype]').val('').siblings('select').val('');
        $parent.find('input[rel=idno]').val('');
        $parent.find('input[rel=idnoperiod]').attr('datatype', 'd').removeAttr('disabled').val('');
        $parent.find('input[rel=idnoperiodcheck]').val('False').closest('dd').find('a.checkbox').removeClass('selected');
        $parent.find('input[rel=idcard]').val('');
        $parent.find('input[rel=idcardperiod]').attr('datatype', 'd').removeAttr('disabled').val('');
        $parent.find('input[rel=idcardperiodcheck]').val('False').closest('dd').find('a.checkbox').removeClass('selected');
        // Update Start by Kevin 2020/03/31 ITSR014316 UAT中出现的defect的修改
        //$parent.find('input[rel=age]').val('');
        $parent.find("input[rel=age]:not('#ApplicantBrithDate')").val('');
        // Update End by Kevin 2020/03/31 ITSR014316 UAT中出现的defect的修改
        //隐藏身份证信息
        $('.layui-order-form .step-form .idcard-info').hide();
    }
    //通知验证
    //$(".layui-order-form input").blur();
    layer.close(layer_country);
})
//国籍选择窗口关闭
$(document).on('click', '.countryBox a.close', function () {
    layer.close(layer_country);
})
// Add by Xu Lei End on 2019.9.3

// =====2019.11.1 职业和类别 更新
//刷新 Input控件的Attribute
function RefreshInputAttribute(flag) {
    $("#step-insured .step-info-box .step-info").each(function (i, curObj) {
        $(curObj).find("ul input").each(function (j) {
            switch (j) {
                case 0:
                    $(this).attr("Id", 'InsuredPersons_' + i + '__RELATION_CODE');
                    $(this).attr("name", 'InsuredPersons[' + i + '].RELATION_CODE');
                    $(this).attr("cusType", 'insured_relation');
                    $(this).attr("autocomplete", 'off');
                    break;
                case 1:
                    $(this).attr("Id", 'InsuredPersons_' + i + '__NAME');
                    $(this).attr("name", 'InsuredPersons[' + i + '].NAME');
                    $(this).attr("cusType", 'insured_name');
                    $(this).attr("autocomplete", 'off');
                    break;
                // Update by Xu Lei Start on 2019.9.3
                case 2:
                    $(this).attr("Id", 'InsuredPersons_' + i + '__GENDER');
                    $(this).attr("name", 'InsuredPersons[' + i + '].GENDER');
                    $(this).attr("autocomplete", 'off');
                    break;
                case 3:
                    $(this).attr("Id", 'InsuredPersons_' + i + '__NATIONALITY');
                    $(this).attr("name", 'InsuredPersons[' + i + '].NATIONALITY');
                    $(this).attr("cusType", 'insured_nationality');
                    $(this).attr("autocomplete", 'off');
                    break;
                case 4:
                    $(this).attr("Id", 'InsuredPersons_' + i + '__BIRTH_DATE');
                    $(this).attr("name", 'InsuredPersons[' + i + '].BIRTH_DATE');
                    $(this).attr("cusType", 'insured_birthday');
                    $(this).attr("autocomplete", 'off');
                    break;
                case 5:
                    $(this).attr("Id", 'InsuredPersons_' + i + '__ID_TYPE_ID');
                    $(this).attr("name", 'InsuredPersons[' + i + '].ID_TYPE_ID');
                    $(this).attr("cusType", 'insured_idtype');
                    $(this).attr("autocomplete", 'off');
                    break;
                case 6:
                    $(this).attr("Id", 'InsuredPersons_' + i + '__ID_NO');
                    $(this).attr("name", 'InsuredPersons[' + i + '].ID_NO');
                    $(this).attr("cusType", 'insured_idno');
                    $(this).attr("autocomplete", 'off');
                    break;
                case 7:
                    $(this).attr("Id", 'InsuredPersons_' + i + '__ID_NO_PERIOD');
                    $(this).attr("name", 'InsuredPersons[' + i + '].ID_NO_PERIOD');
                    $(this).attr("cusType", 'insured_idnoperiod');
                    $(this).attr("autocomplete", 'off');
                    break;
                case 8:
                    $(this).attr("Id", 'InsuredPersons_' + i + '__ID_CARD');
                    $(this).attr("name", 'InsuredPersons[' + i + '].ID_CARD');
                    $(this).attr("cusType", 'insured_idcard');
                    $(this).attr("autocomplete", 'off');
                    break;
                case 9:
                    $(this).attr("Id", 'InsuredPersons_' + i + '__ID_CARD_PERIOD');
                    $(this).attr("name", 'InsuredPersons[' + i + '].ID_CARD_PERIOD');
                    $(this).attr("cusType", 'insured_idcardperiod');
                    $(this).attr("autocomplete", 'off');
                    break;
                case 10:
                    $(this).attr("Id", 'InsuredPersons_' + i + '__MOBILE');
                    $(this).attr("name", 'InsuredPersons[' + i + '].MOBILE');
                    $(this).attr("cusType", 'insured_mobile');
                    $(this).attr("autocomplete", 'off');
                    break;
                case 11:
                    $(this).attr("Id", 'InsuredPersons_' + i + '__LIVE_CITY');
                    $(this).attr("name", 'InsuredPersons[' + i + '].LIVE_CITY');
                    $(this).attr("cusType", 'insured_livecity');
                    $(this).attr("autocomplete", 'off');
                    $(this).attr("data-toggle", 'city-picker');
                    break;
                case 12:
                    $(this).attr("Id", 'InsuredPersons_' + i + '__LIVE_ADDRESS');
                    $(this).attr("name", 'InsuredPersons[' + i + '].LIVE_ADDRESS');
                    $(this).attr("cusType", 'insured_liveaddress');
                    $(this).attr("autocomplete", 'off');
                    break;
                case 13:
                    $(this).attr("Id", 'InsuredPersons_' + i + '__JOB_CAREER');
                    $(this).attr("name", 'InsuredPersons[' + i + '].JOB_CAREER');
                    $(this).attr("cusType", 'insured_jobcareer');
                    $(this).attr("autocomplete", 'off');
                    break;
                case 14:
                    $(this).attr("Id", 'InsuredPersons_' + i + '__JOB_COMPANY');
                    $(this).attr("name", 'InsuredPersons[' + i + '].JOB_COMPANY');
                    $(this).attr("cusType", 'insured_jobcompany');
                    $(this).attr("autocomplete", 'off');
                    break;
                case 15:
                    $(this).attr("Id", 'InsuredPersons_' + i + '__JOB_INCOME');
                    $(this).attr("name", 'InsuredPersons[' + i + '].JOB_INCOME');
                    $(this).attr("cusType", 'insured_jobincome');
                    $(this).attr("autocomplete", 'off');
                    break;
                default:
                    break;
                // Update by Xu Lei End on 2019.9.3
            }
        });
    });

};
// =====2019.11.1 职业和类别 更新 end
$(function () {
    //控制历史下拉是否显示
    if ($("#IsSessionUserinfo").val() != "true") {
        HistoryOrder_Hidden();
    }
    //$("#ApplicantName").addClass("HistoryOrder_bg_none");

    //打开或关闭导航菜单
    $('.menu').on('click', function (event) {

        event.preventDefault();
        //若动画正在进行，则停止
        if (!isLateralNavAnimating) {
            if ($(this).parents('.csstransitions').length > 0)
                isLateralNavAnimating = true;

            $('body').toggleClass('navigation-is-open');
            $('.drop-nav').one('webkitTransitionEnd otransitionend oTransitionEnd msTransitionEnd transitionend', function () {
                //动画结束
                isLateralNavAnimating = false;
            });
        }
    });

    //监听登录
    // Update Start by Kevin 2019/01/03 ETV.CHI.G1.001.003.78 在购买页面登陆时，历史投被保人信息无法带出
    //$("#ViewUserIsLogin").bind('DOMNodeInserted', function (e) {
    $("#ViewUserIsLogin, .rightlinks").bind('DOMNodeInserted', function (e) {
        // Update End by Kevin 2019/01/03 ETV.CHI.G1.001.003.78 在购买页面登陆时，历史投被保人信息无法带出

        var element = $(e.target).html();
        //login in
        if (element.indexOf("退出") > -1) {
            // alert("退出");
            //历史订单是否出现
            HistoryOrder_block();
            var username = $(".username").html();
            $(".login-tip-txt").css("display", "none");
        }
        //login out
        if (element.indexOf("登录") > -1) {
            //alert("登录");
            //历史订单是否出现
            HistoryOrder_Hidden();
            $("#IsPersonForDropdown").val("");
            $("#PersonForDropdown").val("");
            $(".login-tip-txt").css("display", "block");
        }
        //login in
        if (element.indexOf("退出") > -1) {
            $("#IsSaveUserSession").val("true");
            InsuredPerson_Load();
            //异步保存订单
            formSubmitByAjax(true);
        }
        //login out
        else {
            $("#IsSaveUserSession").val("");
            InsuredPerson_Load(true);
        }
    });

    //初始化询价
    //update by lisa 2020 解决手机端购买页面初始话询价写死的问题，目前都是IPA 和GBA 产品，都是年计划，跟PC 参数FullYearFlag 写成死的true start
    init_InquiryPrice(($("#FullYearFlag").val() == "True") || ($("#FullYearFlag").val() == "true"));
    //init_InquiryPrice();
    //update by lisa 2020 解决手机端购买页面初始话询价写死的问题，目前都是IPA 和GBA 产品，都是年计划，跟PC 参数FullYearFlag 写成死的true end
    //初次加载调用下列列表中的数据
    InsuredPerson_Load();


    //下拉选择结果获取和判断 
    $(document).on('blur', '.item-control input[rel=province]', function () {
        //快递省份
        $boxscroll.closest('.step-form').find("select[name=province] option:first").prop("selected", 'selected');
    });

    //下拉选择结果获取和判断 
    $(document).on('change', '.item-control select:not(.selecthistory)', function () {
        var $boxscroll = $(this);
        var v = $boxscroll.val();
        if ($boxscroll.siblings('input').val() == v)
            return false;
        $boxscroll.siblings('input').val(v).blur();

        //快递省份
        if ($boxscroll.siblings('input').attr('rel') == 'province') {
            $boxscroll.closest('.step-form').find("select[name=province] option:first").prop("selected", 'selected');
        }

        //投保关系
        if ($boxscroll.siblings('input').attr('rel') == 'relation') {
            ClearApplicantErrormsg("insured");
            $boxscroll.closest('dd').next('dd').hide();
            // UP：2020.02.22
            $boxscroll.closest('.step-form').find('input[type=text],input[type=tel],input[type=number]').val('');

            // Add by Xu Lei Start on 2019.9.3
            // 国籍默认中国
            // 身份证信息字段隐藏
            // 证件有效期按钮取消选择，默认值重置
            var $parent = $boxscroll.closest('.step-form');
            $parent.find('input[rel=nationality]').val('中国');
            // Update by Xu Lei at 2020.11.03 for 添加百万医疗DTC Start
            if ($("input[name='ProductCode']").val() == '180301' || $("input[name='ProductCode']").val() == '180302' || $("input[name='ProductCode']").val() == '18030101') {
                $parent.find('input[rel=idtype]').val('身份证');
            }
            // Update by Xu Lei at 2020.11.03 for 添加百万医疗DTC End
            $parent.find('.idcard-info').hide();
            $parent.find('input[rel=idnoperiod]').val('').removeAttr('disabled');// 证件号码有效期
            $parent.find('.idcard-info input').val('').removeAttr('disabled').attr('ignore', 'ignore').removeClass('Validform_error Validform_error2');//身份证号码、有效期
            $parent.find('input[rel=idnoperiodcheck],input[rel=idcardperiodcheck]').val('False') & $parent.find('.checkbox.selected').removeClass('selected');
            $parent.find('input[custype=insured_idnoperiodcheck]').closest('dd').find('a.checkbox').removeClass('disabled');//add by eren 去掉长期有效不可选
            $parent.find('input[custype=insured_idcardperiodcheck]').closest('dd').find('a.checkbox').removeClass('disabled');//add by eren 去掉长期有效不可选
            // Add by Xu Lei End on 2019.9.3

            $boxscroll.closest('.step-form').find("select[name=idtype] option:first").prop("selected", 'selected');           
                $boxscroll.closest('.step-form').find("select[name=relation] option:first").prop("selected", 'selected');
           
            if (v == '本人') {
                if ($('#insured-oneself').length > 0) {
                    var ii = $('#insured-oneself').index();
                    if (insured != ii) {
                        $boxscroll.siblings('input').addClass('Validform_error').val('只能为本人投保一次');
                        return false;
                    }
                }

                // 投保人性别为男时提示【请正确填写被保险人信息】
                if(aig_orderStorage.applicant.sex=='True'){
                    
                    $boxscroll.siblings('input').addClass('Validform_error').val('请正确填写被保险人信息');
                        return false;
                }

                $boxscroll.closest('dd').next('dd').show();
                $('.layui-order-form .step-form input[custype=insured_name]').val(aig_orderStorage.applicant.name);
                //$('.layui-order-form .step-form input[custype=insured_birthday]').val(aig_orderStorage.applicant.birthday);//update by eren 20190929 将出生日期赋值放到后面
                $('.layui-order-form .step-form input[custype=insured_idtype]').val(aig_orderStorage.applicant.idtype);

                //add by eren 20200312 填充本人信息时，根据证件类型修改证件输入框的校验规则 start
                //是身份证 需要切换验证表达式
                var datatype = aig_orderStorage.applicant.idtype == '身份证' ? 'idcard' : 'no';
                ordervalid.addRule([
                    {
                        ele: $('.layui-order-form .step-form input[custype=insured_idno]'),
                        datatype: datatype
                    }
                ]);
                //add by eren 20200312 填充本人信息时，根据证件类型修改证件输入框的校验规则 end

                $('.layui-order-form .step-form input[custype=insured_idno]').val(aig_orderStorage.applicant.idno);
                $('.layui-order-form .step-form input[custype=insured_mobile]').val(aig_orderStorage.applicant.mobile);
                $('.layui-order-form .step-form input[custype=insured_gender]').val(aig_orderStorage.applicant.sex == 'True' ? 'True' : 'False');
                $('.layui-order-form .step-form input, .layui-order-form .step-form select').attr('disabled', 'disabled').blur() & $('.layui-order-form .step-form .v2-radio-box ul li a').addClass('disabled');
                $boxscroll.removeAttr('disabled');
                $('.layui-order-form .step-form .v2-radio-box ul li a').removeClass('selected') & $('.layui-order-form .step-form .v2-radio-box ul li:eq(' + (aig_orderStorage.applicant.sex == 'True' ? 0 : 1) + ') a').addClass('selected');

                // Add by Xu Lei Start on 2019.9.3 新增字段数据获取、显示
                $parent.find('input[custype=insured_nationality]').val(aig_orderStorage.applicant.nationality);// 国籍
                $parent.find('input[custype=insured_idnoperiod]').val(aig_orderStorage.applicant.idnoperiod).blur();// 证件有效期
                $parent.find('input[custype=insured_idnoperiodcheck]').val(aig_orderStorage.applicant.idnoperiodcheck);// 证件有效期按钮

                $('.layui-order-form .step-form input[custype=insured_birthday]').val(aig_orderStorage.applicant.birthday).blur();

                $parent.find('input[custype=insured_idnoperiodcheck]').closest('dd').find('a.checkbox').addClass('disabled');
                if (aig_orderStorage.applicant.idnoperiodcheck == 'True') {
                    $parent.find('input[custype=insured_idnoperiodcheck]').closest('dd').find('a.checkbox').addClass('selected');
                    $parent.find('input[custype=insured_idnoperiod]').attr('datatype', '*').removeClass('Validform_error Validform_error2');
                }
                //update by qufeng 2023/11/24 选择本人禁止选择所在地
                $parent.find('input[custype=insured_livecity]').val(aig_orderStorage.applicant.livecity).removeClass('Validform_error Validform_error2').css("pointer-events", "none");// 居住地址 

                $parent.find('input[custype=insured_liveaddress]').val(aig_orderStorage.applicant.liveaddress).removeClass('Validform_error Validform_error2');// 详细地址
                $parent.find('input[custype=insured_jobcompany]').val(aig_orderStorage.applicant.jobcompany);// 工作单位
                $parent.find('input[custype=insured_jobcareer]').val(aig_orderStorage.applicant.jobcareer).removeClass('Validform_error Validform_error2');// 职业
                $parent.find('input[custype=insured_jobincome]').val(aig_orderStorage.applicant.jobincome);// 收入

                //国籍：中国，证件类型：护照；显示身份证信息字段//update by eren 20190929 修改身份证框出现的条件
                if (aig_orderStorage.applicant.nationality == '中国' && aig_orderStorage.applicant.idtype != '身份证') {
                    $parent.find('.idcard-info').show();
                    $parent.find('input[custype=insured_idcard]').val(aig_orderStorage.applicant.idcard);// 身份证号码
                    $parent.find('input[custype=insured_idcardperiod]').val(aig_orderStorage.applicant.idcardperiod);// 身份证有效期
                    $parent.find('input[custype=insured_idcardperiodcheck]').val(aig_orderStorage.applicant.idcardperiodcheck);// 身份证有效期按钮

                    $parent.find('input[custype=insured_idcardperiodcheck]').closest('dd').find('a.checkbox').addClass('disabled');
                    if (aig_orderStorage.applicant.idcardperiodcheck == 'True') {
                        $parent.find('input[custype=insured_idcardperiodcheck]').closest('dd').find('a.checkbox').addClass('selected');
                        $parent.find('input[custype=insured_idcardperiod]').attr('datatype', '*').removeClass('Validform_error Validform_error2');
                    }
                }
                // Add by Xu Lei End on 2019.9.3

                //add by eren 20191101 证件类型为身份证时才显示永久有效的框 start
                if ($('.layui-order-form .step-form input[custype=insured_idtype]').val() == "身份证") {
                    $parent.find('input[custype=insured_idnoperiodcheck]').parent().show();// 证件有效期按钮
                }
                else {
                    $parent.find('input[custype=insured_idnoperiodcheck]').parent().hide();// 证件有效期按钮
                }
                //add by eren 20191101 证件类型为身份证时才显示永久有效的框 end

                //第一次选择本人时候 隐藏选择本人的提示
                $(".layui-order-form .step-form .tip-relation").hide();
            } else {
                $('.layui-order-form .step-form input, .layui-order-form .step-form select').removeAttr('disabled', 'disabled') & $('.layui-order-form .step-form .v2-radio-box ul li a').removeClass('disabled');
                // Add by Xu Lei at 2020.11.04 for 添加百万医疗DTC Start
                if ($("input[name='ProductCode']").val() == '180301' || $("input[name='ProductCode']").val() == '180302' || $("input[name='ProductCode']").val() == '18030101') {
                    $parent.find('input[rel=nationality]').attr('disabled', 'disabled');
                    $parent.find('input[rel=age]').attr('disabled', 'disabled');
                }
                // Add by Xu Lei at 2020.11.04 for 添加百万医疗DTC End
                //update by qufeng 2023/11/24 可选所在地
                $parent.find('input[custype=insured_livecity]').css("pointer-events", "auto");// 居住地址 
            }
            $boxscroll.siblings('input').val(v).removeAttr('disabled').blur();
        }

        //证件类型
        if ($boxscroll.siblings('input').attr('rel') == 'idtype') {
            //证件号码清空
            $boxscroll.closest('.item-control').siblings('.item-control').find('input[rel=idno]').removeClass('Validform_error').val('');
            //清空上一次验证信息【解决证件】

            //$boxscroll.closest('.item-control').siblings('.item-control').find('input[rel=idno]').blur();
            //add by eren 20191014 清空证件信息 start
            var $parent = $('.layui-order-form .step-form');
            $parent.find('input[rel=idno]').val('');
            $parent.find('input[rel=idnoperiod]').attr('datatype', 'd').removeAttr('disabled').val('');
            $parent.find('input[rel=idnoperiodcheck]').val('False').closest('dd').find('a.checkbox').removeClass('selected');
            $parent.find('input[rel=idcard]').val('');
            $parent.find('input[rel=idcardperiod]').attr('datatype', 'd').removeAttr('disabled').val('');
            $parent.find('input[rel=idcardperiodcheck]').val('False').closest('dd').find('a.checkbox').removeClass('selected');
            // Update Start by Kevin 2020/03/31 ITSR014316 UAT中出现的defect的修改
            //$parent.find('input[rel=age]').val('');
            $parent.find("input[rel=age]:not('#ApplicantBrithDate')").val('');
            // Update End by Kevin 2020/03/31 ITSR014316 UAT中出现的defect的修改
            //add by eren 20191014 清空证件信息 end

            //add by eren 20190927 地区为中国且非身份证添加身份证和身份证有效期校验 start
            if ($('.layui-order-form #ApplicantIdType').val() != "身份证" && $(".layui-order-form #ApplicantNationality").val() == "中国") {
                $('.layui-order-form input[id=ApplicantIdCard]').removeAttr('ignore');
                // UP：2020.02.22
                // $('.layui-order-form #ApplicantIdCardPeriod').removeAttr('ignore');
                if ($('.layui-order-form input[id=ApplicantIdCard]').val() == "") {
                    $('.layui-order-form input[id=ApplicantIdCard]').addClass('Validform_error');
                }
                // UP：2020.02.22
                /*if ($('.layui-order-form #ApplicantIdCardPeriod').val() == "") {
                    $('.layui-order-form #ApplicantIdCardPeriod').addClass('Validform_error');
                }*/
            }
            else {
                $('.layui-order-form input[id=ApplicantIdCard]').attr('ignore', 'ignore');
                $('.layui-order-form #ApplicantIdCardPeriod').attr('ignore', 'ignore');
            }

            if ($('.layui-order-form #InsuredIdType').val() != "身份证" && $(".layui-order-form #InsuredNationality").val() == "中国") {
                $('.layui-order-form input[id=InsuredIdCard]').removeAttr('ignore');
                // UP：2020.02.22
                //$('.layui-order-form #InsuredIdCardPeriod').removeAttr('ignore');
                if ($('.layui-order-form input[id=InsuredIdCard]').val() == "") {
                    $('.layui-order-form input[id=InsuredIdCard]').addClass('Validform_error');
                }
                // UP：2020.02.22
                /*if ($('.layui-order-form #InsuredIdCardPeriod').val() == "") {
                    $('.layui-order-form #InsuredIdCardPeriod').addClass('Validform_error');
                }*/
            }
            else {
                $('.layui-order-form input[id=InsuredIdCard]').attr('ignore', 'ignore');
                $('.layui-order-form #InsuredIdCardPeriod').attr('ignore', 'ignore');
            }
            //add by eren 20190927 地区为中国且非身份证添加身份证和身份证有效期校验 end

            // UP：2020.02.22
            //add by eren 20191015 证件类型为身份证时才显示永久有效的框 start
            /*if ($('.layui-order-form #ApplicantIdType').val() == "身份证") {
                $('.layui-order-form input[id=ApplicantIdNoPeriodCheck]').parent().show();
            }
            else {
                $('.layui-order-form input[id=ApplicantIdNoPeriodCheck]').parent().hide();
            }
            if ($('.layui-order-form #InsuredIdType').val() == "身份证") {
                $('.layui-order-form input[id=InsuredIdNoPeriodCheck]').parent().show();
            }
            else {
                $('.layui-order-form input[id=InsuredIdNoPeriodCheck]').parent().hide();
            }*/
            // UP：2020.02.22
            $('.layui-order-form input[rel=idnoperiod]').parent().next().hide();
            if(v=='身份证'){
                $('.layui-order-form input[rel=idnoperiod]').parent().next().show();
            }
            //add by eren 20191015 证件类型为身份证时才显示永久有效的框 end

            //是身份证 需要切换验证表达式
            var datatype = v == '身份证' ? 'idcard' : 'no';

            ordervalid.addRule([
                {
                    ele: $boxscroll.closest('.item-control').siblings('.item-control').find('input[rel=idno]'),
                    datatype: datatype
                }
            ]);
            //身份证联动
            disabledSexAndBirthday($boxscroll, v);
        }
        //修复被保人可以选择‘请选择’
        if ($boxscroll.siblings('input').attr('rel') !== 'relation') {
            //验证当前控件的值
            $(this).siblings('input').removeClass('Validform_error').blur();
        }
        else {
            $boxscroll.val('');
        }

    });

    //历史投保人
    $(document).on('change', '.item-control .selec_Applicant', function () {
        if ($(this).find("option:selected").val() != undefined && $(this).find("option:selected").val() != "请选择") {
            var PersonInfo = JSON.parse($(this).find("option:selected").val());
            //alert(PersonInfo);
            //alert(PersonInfo.ApplicantSex);
            $('.layui-order-form #ApplicantName').val(PersonInfo.ApplicantName);

            //update by Eren js升级的代码 20190419 start
            //$('.layui-order-form #ApplicantGender').val("True" == PersonInfo.ApplicantSex ? 'True' : 'False');
            //性别
            $('.layui-order-form #ApplicantGender').val(true == PersonInfo.ApplicantSex ? 'True' : 'False');
            //update by Eren js升级的代码 20190419 end

            //护照
            $('.layui-order-form #ApplicantIdType').val(PersonInfo.ApplicantIdType);
            if (PersonInfo.ApplicantIdType == '护照') {
                //证件号赋值
                //微信小程序找不到 add by hufei
                $('.layui-order-form input[id=ApplicantIdNumber]').val(PersonInfo.passportNumber);
                //$('.layui-order-form #ApplicantIdNumber').val(PersonInfo.passportNumber);
                $('.layui-order-form #ApplicantIdNoPeriod').val(PersonInfo.passPortExprDt);
                if (PersonInfo.passPortExprDt != '9999-12-31') {
                    $($('.layui-order-form a.checkbox')[0]).removeClass('selected');
                } else {
                    $($('.layui-order-form a.checkbox')[0]).addClass('selected');
                }

                //$('.layui-order-form #ApplicantIdCard').val(PersonInfo.idCardNumber);
                $('.layui-order-form input[id=ApplicantIdCard]').val(PersonInfo.idCardNumber);//update by eren 20191009 微信端找不到对象
                $('.layui-order-form #ApplicantIdCardPeriod').val(PersonInfo.idCardExprDt);

                if (PersonInfo.idCardExprDt != '9999-12-31') {
                    $($('.layui-order-form a.checkbox')[1]).removeClass('selected');
                } else {
                    $($('.layui-order-form a.checkbox')[1]).addClass('selected');
                }

            } else if (PersonInfo.ApplicantIdType == '身份证') {
                $('.layui-order-form input[id=ApplicantIdNumber]').val(PersonInfo.idCardNumber);
                //$('.layui-order-form #ApplicantIdNumber').val(PersonInfo.idCardNumber);
                $('.layui-order-form #ApplicantIdNoPeriod').val(PersonInfo.idCardExprDt);

                if (PersonInfo.idCardExprDt != '9999-12-31') {
                    $($('.layui-order-form a.checkbox')[0]).removeClass('selected');
                } else {
                    $($('.layui-order-form a.checkbox')[0]).addClass('selected');
                }
            } else {
                //其他的证件号赋值
                $('.layui-order-form input[id=ApplicantIdNumber]').val(PersonInfo.ApplicantIdNumber);
                //$('.layui-order-form #ApplicantIdNumber').val(PersonInfo.ApplicantIdNumber);
                $('.layui-order-form #ApplicantIdNoPeriod').val(PersonInfo.ApplicantIdExprDt);
                if (PersonInfo.ApplicantIdExprDt != '9999-12-31') {
                    $($('.layui-order-form a.checkbox')[0]).removeClass('selected');
                } else {
                    $($('.layui-order-form a.checkbox')[0]).addClass('selected');
                }

                //$('.layui-order-form #ApplicantIdCard').val(PersonInfo.idCardNumber);
                $('.layui-order-form input[id=ApplicantIdCard]').val(PersonInfo.idCardNumber);//update by eren 20191009 微信端找不到对象
                $('.layui-order-form #ApplicantIdCardPeriod').val(PersonInfo.idCardExprDt);

                if (PersonInfo.idCardExprDt != '9999-12-31') {
                    $($('.layui-order-form a.checkbox')[1]).removeClass('selected');
                } else {
                    $($('.layui-order-form a.checkbox')[1]).addClass('selected');
                }

            }

            // $('.layui-order-form #ApplicantIdType').closest('dl').find('#ApplicantIdNumber').val(PersonInfo.ApplicantIdNumber);      

            //出生日期
            $('.layui-order-form #ApplicantBrithDate').val(PersonInfo.ApplicantBrithDate);

            //电话号码
            $('.layui-order-form #ApplicantMobile').val(PersonInfo.ApplicantMobile);
            //邮件地址
            $('.layui-order-form #ApplicantEmail').val(PersonInfo.ApplicantEmail);

            //所在地
            if (PersonInfo.province != null && PersonInfo.province != "") {
                $('.layui-order-form #ApplicantArea').val(PersonInfo.province);
            }
            else {
                $('.layui-order-form #ApplicantArea').val(null);
            }
             //update by qufeng 2023.11.22 投被保人地址修改 start
            ////居住地址
            ////if (!PersonInfo.province && !PersonInfo.city) {//update by eren 20190930地址能够填入null/null
            //if (PersonInfo.province != null && PersonInfo.province != "" && PersonInfo.city != null && PersonInfo.city != "") {
            //    $('.layui-order-form #ApplicantLiveCity').val(PersonInfo.province + "/" + PersonInfo.city);
            //}
            //else {
            //    $('.layui-order-form #ApplicantLiveCity').val(null);
            //}
             //update by qufeng 2023.11.22 投被保人地址修改 end
            //祥细地址
            $('.layui-order-form #ApplicantLiveAddress').val(PersonInfo.familyAddress);

            //工作单位
            //$('.layui-order-form #ApplicantJobCompany').val(PersonInfo.companyName);
            $('.layui-order-form input[id=ApplicantJobCompany]').val(PersonInfo.companyName);//update by eren 20191030 微信端直接通过id找不到对象

            //国家
            //$('.layui-order-form #ApplicantNationality').val();
            if (PersonInfo.nation != null) {
                $('.layui-order-form #ApplicantNationality').val(PersonInfo.nation.nationNm);
            }


            //职业
            if (PersonInfo.occpt != null) {
                $('.layui-order-form #ApplicantJobCareer').val(PersonInfo.occpt.ocpNm);
            }
            //收入
            $('.layui-order-form #ApplicantJobIncome').val(PersonInfo.annualIncome);


            //update by Eren js升级的代码 20190419 start
            //$('.layui-order-form .step-form .v2-radio-box ul li a').removeClass('selected') & $('.layui-order-form .step-form .v2-radio-box ul li:eq(' + (PersonInfo.ApplicantSex == "True" ? 0 : 1) + ') a').addClass('selected');
            $('.layui-order-form .step-form .v2-radio-box ul li a').removeClass('selected') & $('.layui-order-form .step-form .v2-radio-box ul li:eq(' + (PersonInfo.ApplicantSex == true ? 0 : 1) + ') a').addClass('selected');
            //update by Eren js升级的代码 20190419 end

            //add by eren 20190927 自动填充时地区为中国且非身份证添加身份证和身份证有效期校验 start     
            if ($('.layui-order-form #ApplicantIdType').val() != "身份证" && $(".layui-order-form #ApplicantNationality").val() == "中国") {
                $('.layui-order-form input[id=ApplicantIdCard]').removeAttr('ignore');
                $('.layui-order-form #ApplicantIdCardPeriod').removeAttr('ignore');
                $('.layui-order-form .idcard-info').show();
            }
            else {
                $('.layui-order-form input[id=ApplicantIdCard]').attr('ignore', 'ignore');
                $('.layui-order-form #ApplicantIdCardPeriod').attr('ignore', 'ignore');
                $('.layui-order-form .idcard-info').hide();
            }
            //add by eren 20190927 自动填充时地区为中国且非身份证添加身份证和身份证有效期校验 end

            //add by eren 20191015 证件类型为身份证时才显示永久有效的框 start
            if ($('.layui-order-form #ApplicantIdType').val() == "身份证") {
                $('.layui-order-form input[id=ApplicantIdNoPeriodCheck]').parent().show();
            }
            else {
                $('.layui-order-form input[id=ApplicantIdNoPeriodCheck]').parent().hide();
            }
            //add by eren 20191015 证件类型为身份证时才显示永久有效的框 end

            //清空选中项
            $(this).val('');
            $('.layui-order-form .step-form').find("select[name=idtype] option:first").prop("selected", 'selected');

            //历史下拉自动填充数据清除之前的错误消息
            //ClearApplicantErrormsg("Applicant");//update by eren 20191015 解决重复填充同一个人报错消失

            //验证填充的投保人出生日期
            $('.layui-order-form #ApplicantBrithDate').blur();

            //身份证联动
            disabledSexAndBirthday($('.layui-order-form #ApplicantIdType'), PersonInfo.ApplicantIdType);

            //身份证自动填充性别&出生日期
            $('.layui-order-form #ApplicantIdNumber').blur();

            //检测证件号码是否有重复
            checkApplicantDuplicate();

            //input框验证 add by hufei//update by eren 20191008 隐藏的控件不触发校验
            //$('.layui-order-form input').blur();
            $('.layui-order-form input').each(function () {
                if ($(this).closest("dl").css("display") != "none") {
                    $(this).blur();
                }
            })
        }
    });

    //历史被保人
    $(document).on('change', '.item-control .select_InsuredPerson', function () {
        if ($(this).find("option:selected").val() != undefined && $(this).find("option:selected").val() != "请选择") {
            var PersonInfo = JSON.parse($(this).find("option:selected").val());
            //alert(PersonInfo);
            //alert(PersonInfo.ApplicantSex);

            //update by Eren js升级的代码 20190419 start
            //$('.layui-order-form #InsuredName').val(PersonInfo.InseredName);
            $('.layui-order-form input[id=InsuredName]').val(PersonInfo.InseredName);
            //update by Eren js升级的代码 20190419 start

            $('.layui-order-form #InsuredGender').val(true == PersonInfo.InseredSex ? 'True' : 'False');
            $('.layui-order-form #InsuredBrithDate').val(PersonInfo.InseredBrithDate);
            $('.layui-order-form #InsuredIdType').val(PersonInfo.InseredIdType);

            //update by Eren js升级的代码 20190419 start
            //$('.layui-order-form #InsuredIdNumber').val(PersonInfo.InseredIdNumber);
            //$('.layui-order-form #InsuredIdType').closest('dl').find('#InsuredIdNumber').val(PersonInfo.InseredIdNumber);
            //update by Eren js升级的代码 20190419 end

            $('.layui-order-form #InsuredMobile').val(PersonInfo.InseredMobile);
            // $('.layui-order-form #InsuredRelation').val(aig_orderStorage.insured[i].relation);
            $('.layui-order-form .step-form .v2-radio-box ul li a').removeClass('selected') & $('.layui-order-form .step-form .v2-radio-box ul li:eq(' + (PersonInfo.InseredSex == true ? 0 : 1) + ') a').addClass('selected');
            //清空选中项
            $(this).val('');
            $('.layui-order-form .step-form').find("select[name=idtype] option:first").prop("selected", 'selected');


            //护照
            $('.layui-order-form #ApplicantIdType').val(PersonInfo.InseredIdType);
            if (PersonInfo.InseredIdType == '护照') {
                //证件号赋值
                $('.layui-order-form input[id=InsuredIdNumber]').val(PersonInfo.passportNumber);//update by eren 20191010 微信端找不到对象
                $('.layui-order-form #InsuredIdNoPeriod').val(PersonInfo.passPortExprDt);

                if (PersonInfo.passPortExprDt != '9999-12-31') {
                    $($('.layui-order-form a.checkbox')[0]).removeClass('selected');
                } else {
                    $($('.layui-order-form a.checkbox')[0]).addClass('selected');
                }

                $('.layui-order-form input[id=InsuredIdCard]').val(PersonInfo.idCardNumber);//update by eren 20191010 微信端找不到对象
                $('.layui-order-form #InsuredIdCardPeriod').val(PersonInfo.idCardExprDt);

                if (PersonInfo.passPortExprDt != '9999-12-31') {
                    $($('.layui-order-form a.checkbox')[1]).removeClass('selected');
                } else {
                    $($('.layui-order-form a.checkbox')[1]).addClass('selected');
                }

            } else if (PersonInfo.ApplicantIdType == '身份证') {
                $('.layui-order-form input[id=InsuredIdNumber]').val(PersonInfo.idCardNumber);//update by eren 20191010 微信端找不到对象
                $('.layui-order-form #InsuredIdNoPeriod').val(PersonInfo.idCardExprDt);

                if (PersonInfo.idCardExprDt != '9999-12-31') {
                    $($('.layui-order-form a.checkbox')[0]).removeClass('selected');
                } else {
                    $($('.layui-order-form a.checkbox')[0]).addClass('selected');
                }

            } else {
                //其他的证件号赋值
                $('.layui-order-form input[id=InsuredIdNumber]').val(PersonInfo.InseredIdNumber);//update by eren 20191010 微信端找不到对象
                $('.layui-order-form #InsuredIdNoPeriod').val(PersonInfo.insuredIdExprDt);

                if (PersonInfo.insuredIdExprDt != '9999-12-31') {
                    $($('.layui-order-form a.checkbox')[0]).removeClass('selected');
                } else {
                    $($('.layui-order-form a.checkbox')[0]).addClass('selected');
                }

                $('.layui-order-form input[id=InsuredIdCard]').val(PersonInfo.idCardNumber);//update by eren 20191010 微信端找不到对象
                $('.layui-order-form #InsuredIdCardPeriod').val(PersonInfo.idCardExprDt);


                if (PersonInfo.idCardExprDt != '9999-12-31') {
                    $($('.layui-order-form a.checkbox')[1]).removeClass('selected');
                } else {
                    $($('.layui-order-form a.checkbox')[1]).addClass('selected');
                }

            }

            // $('.layui-order-form #ApplicantIdType').closest('dl').find('#ApplicantIdNumber').val(PersonInfo.ApplicantIdNumber);

            //update by Eren js升级的代码 20190419 end

            //国籍
            if (PersonInfo.nation != null) {
                $('.layui-order-form #InsuredNationality').val(PersonInfo.nation.nationNm);
            }

            //出生日期
            $('.layui-order-form #ApplicantBrithDate').val(PersonInfo.ApplicantBrithDate);

            //电话号码
            $('.layui-order-form #ApplicantMobile').val(PersonInfo.ApplicantMobile);
            //邮件地址
            $('.layui-order-form #ApplicantEmail').val(PersonInfo.ApplicantEmail);

            //所在地
            if (PersonInfo.province != null && PersonInfo.province != "") {
                $('.layui-order-form #ApplicantArea').val(PersonInfo.province);
            }
            else {
                $('.layui-order-form #ApplicantArea').val(null);
            }
             //update by qufeng 2023.11.22 投被保人地址修改 start
            ////居住地址
            ////if (!PersonInfo.province && !PersonInfo.city) {//update by eren 20190930地址能够填入null/null
            //if (PersonInfo.province != null && PersonInfo.province != "" && PersonInfo.city != null && PersonInfo.city != "") {
            //    $('.layui-order-form #InsuredLiveCity').val(PersonInfo.province + "/" + PersonInfo.city);
            //}
            //else {
            //    $('.layui-order-form #InsuredLiveCity').val(null);
            //}
             //update by qufeng 2023.11.22 投被保人地址修改 end
            //祥细地址
            $('.layui-order-form #InsuredLiveAddress').val(PersonInfo.familyAddress);

            //工作单位
            $('.layui-order-form input[id=InsuredJobCompany]').val(PersonInfo.companyName);//update by eren 20192030 微信端找不到对象

            //职业
            if (PersonInfo.occpt != null) {
                $('.layui-order-form #InsuredJobCareer').val(PersonInfo.occpt.ocpNm);
            }
            //收入
            $('.layui-order-form #InsuredJobIncome').val(PersonInfo.annualIncome);

            //历史下拉自动填充数据清除之前的错误消息
            //ClearApplicantErrormsg("Insured");//update by eren 20191015 解决重复填充同一个人报错消失
            //验证填充的被保人出生日期
            $('.layui-order-form #InsuredBrithDate').blur();
            //身份证联动
            disabledSexAndBirthday($('.layui-order-form #InsuredIdType'), PersonInfo.InseredIdType);
            //验证填充的被保人是否重复 & 选择的是身份证性别和出生日期自动补充

            //触发验证规则

            //input框验证 add by hufei 不要问我为甚魔加
            //add by eren 20190927 自动填充时地区为中国且非身份证添加身份证和身份证有效期校验 start
            if ($('.layui-order-form #InsuredIdType').val() != "身份证" && $(".layui-order-form #InsuredNationality").val() == "中国") {
                $('.layui-order-form input[id=InsuredIdCard]').removeAttr('ignore');
                $('.layui-order-form #InsuredIdCardPeriod').removeAttr('ignore');
                $('.layui-order-form .idcard-info').show();
            }
            else {
                $('.layui-order-form input[id=InsuredIdCard]').attr('ignore', 'ignore');
                $('.layui-order-form #InsuredIdCardPeriod').attr('ignore', 'ignore');
                $('.layui-order-form .idcard-info').hide();
            }
            //add by eren 20190927 自动填充时地区为中国且非身份证添加身份证和身份证有效期校验 end

            //add by eren 20191015 证件类型为身份证时才显示永久有效的框 start
            if ($('.layui-order-form #InsuredIdType').val() == "身份证") {
                $('.layui-order-form input[id=InsuredIdNoPeriodCheck]').parent().show();
            }
            else {
                $('.layui-order-form input[id=InsuredIdNoPeriodCheck]').parent().hide();
            }
            //add by eren 20191015 证件类型为身份证时才显示永久有效的框 end

            //$('.layui-order-form input').blur();
            $('.layui-order-form input').each(function () {
                if ($(this).closest("dl").css("display") != "none") {
                    $(this).blur();
                }
            })
        }
    });

    //历史收件人
    $(document).on('change', '.item-control .selec_Express', function () {
        if ($(this).find("option:selected").val() != undefined && $(this).find("option:selected").val() != "请选择") {
            var PersonInfo = JSON.parse($(this).find("option:selected").val());
            // alert(PersonInfo);
            $("#step-express #ExpressReceiverName").val(PersonInfo.ExpressReceiverName);
            $("#step-express #ExpressReceiverNumber").val(PersonInfo.ExpressReceiverNumber);
            $("#step-express #ExpressReceiverProvince").val(PersonInfo.ExpressReceiverProvince);
            $("#step-express #ExpressReceiverAddress").val(PersonInfo.ExpressReceiverAddress);

            //历史下拉自动填充数据清除之前的错误消息
            $('#step-express #ExpressReceiverName').removeClass('Validform_error');
            $('#step-express #ExpressReceiverNumber').removeClass('Validform_error');
            $('#step-express #ExpressReceiverProvince').removeClass('Validform_error');
            $('#step-express #ExpressReceiverAddress').removeClass('Validform_error');

            //清空选中项
            $(this).val('');
            $('#step-express').find("select[name=province] option:first").prop("selected", 'selected');
        }
    });

    // Add by Xu Lei Start on 2019.9.3 证件有效期复选框按钮
    $(document).on('click', '.v2-checkbox-box ul li a.checkbox', function () {
        var $this = $(this);
        if ($this.hasClass('disabled')) {
            return false;
        }
        var val = $this.attr('data-val');
        $this.toggleClass('selected');
        if ($this.hasClass('selected')) {
            $this.closest('.checkbox-idperiod').find('input').val(val);
            $this.closest('.item-control').prev('.item-control').find('input').val('9999-12-31').attr('datatype', '*').attr('disabled', 'disabled').blur();
        } else {
            $this.closest('.checkbox-idperiod').find('input').val('False');
            $this.closest('.item-control').prev('.item-control').find('input').val('').attr('datatype', 'd').removeAttr('disabled').blur();
        }
    })
    // Add by Xu Lei End on 2019.9.3

    //点击radiobuttopn的事件 性别&是否需要快递纸质保单
    $(document).on('click', '.v2-radio-box ul li a.radio', function () {

        if ($(this).hasClass('disabled')) {
            return false;
        }

        var $this = $(this);


        //纸质保单
        if ($this.closest('.v2-radio-box').find('input:hidden').attr('id') == 'ExpressRequired') {
            var v = $this.attr('data-val');
            $this.toggleClass('selected') & $this.parent().siblings().find('a').removeClass('selected');
            $this.closest('.v2-radio-box').find('input:hidden').val(v).blur();

            $('.express-attention, .step-form-express').toggle();
            $this.closest('.v2-radio-box').find('input:hidden').val('False');
            //$('.step-form-express input').attr('ignore', 'ignore').val('').removeClass('Validform_error').attr('datatype', 's');
            $('.step-form-express input').attr('ignore', 'ignore').val('').removeClass('Validform_error');
            if ($this.hasClass('selected')) {
                $this.closest('.v2-radio-box').find('input:hidden').val('True');
                $('.step-form-express input').removeAttr('ignore');
            }
        }
        //性别
        else {
            var val = $(this).attr('data-val');
            $(this).addClass('selected').parent().siblings().children('a').removeClass('selected');
            $(this).parents('.v2-radio-box').find('input').val(val).blur();
        }
    })

    //绑定弹窗上的投保人资料到页面上去
    function i_applicant() {
        //check duplicate applicant number when modify 
        checkApplicantDuplicate();
        // UP：201912.20
        // $('.layui-order-form input.Validform_error:visible').val('').blur();
        $(".layui-order-form input:visible").each(function(){
            var $input = $(this);
            if($input.val().length==0)
                $input.blur();
        });
        // UP：201912.20 end
        if ($('.layui-order-form .Validform_error').length > 0 )
            return false;
        //add by eren 20191029 验证生日是否符合start
        if (!checkBirthday_applicant()) {
            $('.layui-order-form #ApplicantBrithDate').addClass("Validform_error").blur();
            return false;
        }
        //add by eren 20191029 验证生日是否符合start
        if ($('.layui-order-form input:visible.Validform_error').length > 0 || '' == $('.layui-order-form #ApplicantName').val() || '' == $('.layui-order-form #ApplicantBrithDate').val() || '' == $('.layui-order-form #ApplicantIdType').val() || '' == $('.layui-order-form #ApplicantIdNumber').val() || '' == $('.layui-order-form #ApplicantMobile').val() || '' == $('.layui-order-form #ApplicantEmail').val() || '' == $('.layui-order-form #ApplicantLiveCity').val() || '' == $('.layui-order-form #ApplicantLiveAddress').val())
        //if ($('.layui-order-form input:visible.Validform_error').length > 0 || '' == $('.layui-order-form #ApplicantName').val() || '' == $('.layui-order-form #ApplicantBrithDate').val() || '' == $('.layui-order-form #ApplicantIdType').val() || '' == $('.layui-order-form #ApplicantIdNumber').val() || '' == $('.layui-order-form #ApplicantMobile').val() || '' == $('.layui-order-form #ApplicantEmail').val() /*|| '' == $('.layui-order-form #ApplicantArea').val()*/)
            return false;
        aig_orderStorage.product.days = parseInt(moment(aig_orderStorage.product.enddate).diff(aig_orderStorage.product.startdate, 'days') + 1);
        aig_orderStorage.applicant = {
            'name': $('.layui-order-form #ApplicantName').val().trim(),
            'sex': $('.layui-order-form #ApplicantGender').val(),
            'birthday': $('.layui-order-form #ApplicantBrithDate').val(),
            'idtype': $('.layui-order-form #ApplicantIdType').val(),
            //update by Eren js升级的代码 20190419 start
            'idno': $('.layui-order-form #ApplicantIdType').closest('dl').find('#ApplicantIdNumber').val().trim(),
            //'idno': $('.layui-order-form #ApplicantIdNumber').val().trim(),
            //update by Eren js升级的代码 20190419 end
            'mobile': $('.layui-order-form #ApplicantMobile').val(),
            'email': $('.layui-order-form #ApplicantEmail').val().trim(),
            
            // Add by Xu Lei Start on 2019.9.3 投保人新增字段
            'nationality': $('.layui-order-form #ApplicantNationality').val(),
            'idnoperiod': $('.layui-order-form #ApplicantIdNoPeriod').val(),
            'idnoperiodcheck': $('.layui-order-form #ApplicantIdNoPeriodCheck').val(),
            //'idcard': $('.layui-order-form #ApplicantIdCard').val(),
            'idcard': $('.layui-order-form input[id=ApplicantIdCard]').val(),//update by eren 20191007 微信端直接通过id找不到对象
            'idcardperiod': $('.layui-order-form #ApplicantIdCardPeriod').val(),
            'idcardperiodcheck': $('.layui-order-form #ApplicantIdCardPeriodCheck').val(),
            'livecity': $('.layui-order-form #ApplicantLiveCity').val(),
            'liveaddress': $('.layui-order-form #ApplicantLiveAddress').val(),
            //'jobcompany': $('.layui-order-form #ApplicantJobCompany').val(),
            'jobcompany': $('.layui-order-form input[id=ApplicantJobCompany]').val(),//update by eren 20191030 微信端直接通过id找不到对象
            'jobcareer': $('.layui-order-form #ApplicantJobCareer').val(),
            'jobincome': $('.layui-order-form #ApplicantJobIncome').val(),
            // Add by Xu Lei End on 2019.9.3
            'area': $('.layui-order-form #ApplicantArea').val(), // Update 2022.02.10 for 一生康美 Start
        };
        var tempsex = aig_orderStorage.applicant.sex == "True" ? "男" : "女";
        // Update by Xu Lei Start on 2019.9.3
        var $showbox = $('#step-applicant .step-info-box .step-info ul');
        $showbox.parent().show(),
            $showbox.find('li:eq(0) span').html(aig_orderStorage.applicant.name + '<input  datatype="name" autocomplete="off" class="name" data-val="true" data-val-length="投保人姓名不能超过30位！" data-val-length-max="30" data-val-required="投保人姓名不得为空！" errormsg="请正确输入投保人姓名" id="ApplicantName" maxlength="30" name="ApplicantName" nullmsg="请输入投保人姓名" placeholder="境外游,请填写护照所示英文姓名" rel="name" type="hidden" value="' + aig_orderStorage.applicant.name + '">'),
            $showbox.find('li:eq(1) span').html(tempsex + '<input value="' + aig_orderStorage.applicant.sex + '" id="ApplicantGender" name="ApplicantGender" type="hidden">'),
            $showbox.find('li:eq(4) span:eq(0)').html(aig_orderStorage.applicant.idtype + '<input datatype="s" autocomplete="off" data-val="true" data-val-required="投保人证件类型为必选项" id="ApplicantIdType" name="ApplicantIdType" nullmsg="请选择证件类型" placeholder="境外游，请选择护照" rel="idtype" type="hidden" value="' + aig_orderStorage.applicant.idtype + '" readonly>'),
            $showbox.find('li:eq(4) span:eq(1)').html(aig_orderStorage.applicant.idno + '<input datatype="no" autocomplete="off" class="idno" data-val="true" data-val-length="投保人证件ID不能超过20位！" data-val-length-max="20" data-val-required="证件号码为必填项" errormsg="请正确输入证件号码" id="ApplicantIdNumber" maxlength="18" name="ApplicantIdNumber" nullmsg="请输入证件号码" placeholder="请输入证件号码" rel="idno" type="hidden" value="' + aig_orderStorage.applicant.idno + '">'),
            $showbox.find('li:eq(3) span').html(aig_orderStorage.applicant.birthday + '<input datatype="d,is18Picker" autocomplete="off" data-val="true" data-val-regex="日期格式必须为YYYY-MM-DD" data-val-required="投保人出生日期不得为空！" errormsg="投保人年龄必须大于或等于18岁" id="ApplicantBrithDate" name="ApplicantBrithDate" nullmsg="请选择出生日期" placeholder="投保人年龄必须大于或等于18岁" rel="age" type="hidden" value="' + aig_orderStorage.applicant.birthday + '" readonly>'),
            $showbox.find('li:eq(8) span').html(aig_orderStorage.applicant.mobile + '<input datatype="m" autocomplete="off" data-val="true" data-val-required="投保人电话为必填项" errormsg="请正确输入手机号码" id="ApplicantMobile" maxlength="11" name="ApplicantMobile" nullmsg="请输入手机号码" placeholder="请输入手机号码" rel="m" type="hidden" value="' + aig_orderStorage.applicant.mobile + '">'),
            $showbox.find('li:eq(9) span').html(aig_orderStorage.applicant.email + '<input datatype="e" autocomplete="off" data-val="true" data-val-length="投保人邮箱不能超过50位！" data-val-length-max="50" data-val-regex="投保人邮箱的格式不正确" data-val-regex-pattern="^\w+([-+.]\w+)*\w+([-.]\w+)*\.\w+([-.]\w+)*$" data-val-required="邮箱必填" errormsg="请正确输入邮箱" id="ApplicantEmail" name="ApplicantEmail" nullmsg="请输入邮箱" placeholder="用于接收电子保单" rel="e" type="hidden" value="' + aig_orderStorage.applicant.email + '">');
            //$showbox.find('li:eq(15) span').html(aig_orderStorage.applicant.area + '<input datatype="space" autocomplete="off" data-val="true"  data-val-required="请选择" errormsg="请选择" id="ApplicantArea" name="ApplicantArea" nullmsg="请选择" placeholder="请选择" rel="area" type="hidden" value="' + aig_orderStorage.applicant.area + '">');
        var isshow_idcard = 1;
        if ((aig_orderStorage.applicant.nationality == '中国' && aig_orderStorage.applicant.idtype == '身份证') || (aig_orderStorage.applicant.nationality != '中国')) {
            isshow_idcard = 0;
        }
        var inncomme = aig_orderStorage.applicant.jobincome;
        if (inncomme.indexOf('以上') > 0) {
            inncomme = '50万以上/年';
        } else if (inncomme) {
            inncomme += '万/年';
        }
        $showbox.find('li:eq(2) span').html(aig_orderStorage.applicant.nationality + '<input name="ApplicantNationality" type="hidden" value="' + aig_orderStorage.applicant.nationality + '">'),
            $showbox.find('li:eq(5) span').html(aig_orderStorage.applicant.idnoperiod + '<input name="ApplicantIdNoPeriod" type="hidden" value="' + aig_orderStorage.applicant.idnoperiod + '">'),
            $showbox.find('li:eq(6) span').html(aig_orderStorage.applicant.idcard + '<input name="ApplicantIdCard" type="hidden" value="' + aig_orderStorage.applicant.idcard + '">'),
            $showbox.find('li:eq(7) span').html(aig_orderStorage.applicant.idcardperiod + '<input name="ApplicantIdCardPeriod" type="hidden" value="' + aig_orderStorage.applicant.idcardperiod + '">'),
            $showbox.find('li:eq(10) span').html(aig_orderStorage.applicant.livecity + '<input name="ApplicantLiveCity" type="hidden" value="' + aig_orderStorage.applicant.livecity + '">'),
            $showbox.find('li:eq(11) span').html(aig_orderStorage.applicant.liveaddress + '<input name="ApplicantLiveAddress" type="hidden" value="' + aig_orderStorage.applicant.liveaddress + '">'),
            $showbox.find('li:eq(12) span').html(aig_orderStorage.applicant.jobcareer + '<input name="ApplicantJobCareer" type="hidden" value="' + aig_orderStorage.applicant.jobcareer + '">'),
            $showbox.find('li:eq(13) span').html(aig_orderStorage.applicant.jobcompany + '<input name="ApplicantJobCompany" type="hidden" value="' + aig_orderStorage.applicant.jobcompany + '">'),
            $showbox.find('li:eq(14) span').html(inncomme + '<input name="ApplicantJobIncome" type="hidden" value="' + aig_orderStorage.applicant.jobincome + '">');

        // UP：2020.02.22
        //add by eren 20191029 隐藏非必填 start
        $showbox.find('li:eq(5)').show();
        $showbox.find('li:eq(10)').show();
        $showbox.find('li:eq(11)').show();
        $showbox.find('li:eq(12)').show();
        $showbox.find('li:eq(13)').show();
        $showbox.find('li:eq(14)').show();
        if(aig_orderStorage.applicant.idnoperiod.length==0)
            $showbox.find('li:eq(5)').hide();
        if(aig_orderStorage.applicant.livecity.length==0)
            $showbox.find('li:eq(10)').hide();
        if(aig_orderStorage.applicant.liveaddress.length==0)
            $showbox.find('li:eq(11)').hide();
        if (aig_orderStorage.applicant.jobcareer.length == 0)
            $showbox.find('li:eq(12)').hide();
        if (aig_orderStorage.applicant.jobcompany.length == 0)
            $showbox.find('li:eq(13)').hide();
        //if (aig_orderStorage.applicant.jobcareer.length == 0)
        //    $showbox.find('li:eq(13)').hide();
        if (aig_orderStorage.applicant.jobincome.length == 0)
            $showbox.find('li:eq(14)').hide();
        //add by eren 20191029 隐藏非必填 end

        if (!isshow_idcard)
            $showbox.find('li:eq(6)').hide(), $showbox.find('li:eq(7)').hide();
        else
            $showbox.find('li:eq(6)').show(), $showbox.find('li:eq(7)').show();
        // Update by Xu Lei End on 2019.9.3
        // UP：2020.02.22
        $showbox.find('li:eq(7)').hide();
        if(aig_orderStorage.applicant.idcardperiod.length>0){
            $showbox.find('li:eq(7)').show();
        }
        return true;
    }
    //投保人信息录入
    $(document).on('click', '.btn-add-applicant', function () {
        var $this = $(this);
        layer.open({
            className: 'layui-order-form'
            , title: [
                '<a href="javascript:;" class="layui-order-close"></a>投保人信息',
                'text-align:center !important;text-indent:0;background-color:#fff;'
            ]
            , type: 1
            , content: '<div class="v2-order-step">' + $('#step-applicant .step-form').prop("outerHTML") + '</div>'
            , anim: 'right'
            , style: 'position:fixed; left:0; top:0; width:100%; height:100%; border: none; -webkit-animation-duration: .5s; animation-duration: .5s;'
            , btn: '确认'
            , yes: function (index) {
                var re = i_applicant();
                if (!re)
                    return false;
                $this.hide(), $this.next('p').hide(); layer.closeAll();
                $('body').removeClass('layer-board');
                $body.animate({
                    scrollTop: $('#step-applicant').offset().top - 5
                }, 1000);

                // Add Start by Kevin 2018/11/28 Hotfix_UpliftGridSumDissector 更新国双eTravel检测代码
                //当用户完成投保人信息填写并确认时
                 _gsq.push(["track", "c_interact", { c_page_cate: "保单页", c_botton_cate: "保单页信息填写", c_botton_loc: "投保人信息-确认", c_button_name: "投保人", c_botton_url: "-", c_pro_name: $("#productName").val() }]);
                //alert("投保人信息-确认" + $("#productName").val() + "-" + (($("#PartnerCode").val() == "wechat") ? "WeChat端" : "Mob端"));
                // Add End by Kevin 2018/11/28 Hotfix_UpliftGridSumDissector 更新国双eTravel检测代码

                // Update Start by Kevin 2019/01/21 Hotfix_AddAdobeInspector etravel的购买页面增加ADOBE的监测代码和检测数据PC，WAP，WECHAT端
                UpdateAdobeInspector("9", "投保人信息-确认");
                console.log(digitalData);
                // Update End by Kevin 2019/01/21 Hotfix_AddAdobeInspector etravel的购买页面增加ADOBE的监测代码和检测数据PC，WAP，WECHAT端

            }
        });
        $('body').addClass('layer-board');
        $('.layui-order-form input').removeAttr('ignore');

        // Add by Xu Lei Start on 2019.9.3
        // 非必填项增加ignore属性
        // 证件有效期绑定日期插件
        // 地区选择初始化
        $('.layui-order-form input[data-ignore]').attr('ignore', 'ignore');
        IDperiodpicker('.layui-order-form input[rel=idnoperiod]');
        //new MultiPicker({
        //    input: 'ApplicantLiveCity',//点击触发插件的input框的id
        //    container: 'targetContainer',//插件插入的容器id
        //    jsonData: $city,
        //    success: function (arr) {
        //        $('.layui-order-form #ApplicantLiveCity').val(arr[0].value + '/' + arr[1].value).blur();//update by eren 修改手机端地址显示没有"/"
        //    }//回调
        //});
        $('.layui-order-form input[rel=nationality]').val('中国');
        $('.layui-order-form input[rel=age]').closest('dd').find('.radio').addClass('disabled');
        $('.layui-order-form input[rel=age]').attr("disabled", "disabled");
        // Add by Xu Lei End on 2019.9.3

        // =====2019.11.1 初始化地区、职业选项
        picker_livecity();
        picker_jobcareer();
        // =====2019.11.1 初始化地区、职业选项 end

        $("#IsQuotoPrice").val("0");
        valid();
        birthdaypicker('.layui-order-form .dtpicker_birth');
    })
    //投保人信息修改
    $(document).on('click', '.btn-add-applicant-edit', function () {

        //_gsq.push(["T", "GWD-002498", "trackEvent", "投保人信息", "编辑", location.pathname]);

        ClearApplicantErrormsg("Applicant");
        $("#editstatus").val("true");
        var $this = $(this);
        layer.open({
            className: 'layui-order-form'
            , title: [
                '<a href="javascript:;" class="layui-order-close"></a>投保人信息',
                'text-align:center !important;text-indent:0;background-color:#fff;'
            ]
            , type: 1
            , content: '<div class="v2-order-step">' + $('#step-applicant .step-form').prop("outerHTML") + '</div>'
            , anim: 'right'
            , style: 'position:fixed; left:0; top:0; width:100%; height:100%; border: none; -webkit-animation-duration: .5s; animation-duration: .5s;',
            btn: '确认'
            , yes: function (index) {

                // =====2019.11.1 被保险人为本人联动更新，需要验证年龄是否符合18-55周岁
                if ($('#insured-oneself').length > 0) {
                    if (!checkInsuredAge()) {
                        return false;
                    }
                    if (!checkPlan($('.layui-order-form #ApplicantJobCareer').val())) {
                        return false;
                    }
                }
                // =====2019.11.1 被保险人为本人联动更新，需要验证年龄是否符合18-55周岁 end

                var re = i_applicant();
                if (!re) {
                    return false;
                }
                //如果被保人中有本人，需要重新询价
                if ($('#insured-oneself').length > 0) {
                    UpdateInsuredforOwn();
                    $("#IsQuotoPrice").val("1");
                }
                else {
                    $("#IsQuotoPrice").val("0");
                }
                layer.closeAll();
                $('body').removeClass('layer-board');
                $body.animate({
                    scrollTop: $('#step-applicant').offset().top - 5
                }, 1000);

                // 被保险人下标再整理
                RefreshInputAttribute("itemAdd");

                // Add Start by Kevin 2018/11/28 Hotfix_UpliftGridSumDissector 更新国双eTravel检测代码
                //当用户完成投保人信息填写并确认时
                 _gsq.push(["track", "c_interact", { c_page_cate: "保单页", c_botton_cate: "保单页信息填写", c_botton_loc: "投保人信息-确认", c_button_name: "投保人", c_botton_url: "-", c_pro_name: $("#productName").val() }]);
                //alert("投保人信息-确认" + $("#productName").val() + "-" + (($("#PartnerCode").val() == "wechat") ? "WeChat端" : "Mob端"));
                // Add End by Kevin 2018/11/28 Hotfix_UpliftGridSumDissector 更新国双eTravel检测代码

                // Update Start by Kevin 2019/01/21 Hotfix_AddAdobeInspector etravel的购买页面增加ADOBE的监测代码和检测数据PC，WAP，WECHAT端
                UpdateAdobeInspector("9", "投保人信息-确认");
                console.log(digitalData);
                // Update End by Kevin 2019/01/21 Hotfix_AddAdobeInspector etravel的购买页面增加ADOBE的监测代码和检测数据PC，WAP，WECHAT端

            }
        });

        ClearApplicantErrormsg("Applicant");

        $('body').addClass('layer-board');
        $('.layui-order-form input').removeAttr('ignore');

        // Add by Xu Lei Start on 2019.9.3 非必填项增加ignore属性
        $('.layui-order-form input[data-ignore]').attr('ignore', 'ignore');
        IDperiodpicker('.layui-order-form input[rel=idnoperiod]');
        //new MultiPicker({
        //    input: 'ApplicantLiveCity',//点击触发插件的input框的id
        //    container: 'targetContainer',//插件插入的容器id
        //    jsonData: $city,
        //    success: function (arr) {
        //        $('.layui-order-form #ApplicantLiveCity').val(arr[0].value + '/' + arr[1].value).blur();//update by eren 修改手机端地址显示没有"/"

        //    }//回调
        //});
        // Add by Xu Lei End on 2019.9.3

        //绑定投保人信息到弹窗上去
        $('.layui-order-form #ApplicantName').val(aig_orderStorage.applicant.name),
            $('.layui-order-form #ApplicantGender').val('True' == aig_orderStorage.applicant.sex ? 'True' : 'False'),
            $('.layui-order-form #ApplicantBrithDate').val(aig_orderStorage.applicant.birthday),
            $('.layui-order-form #ApplicantIdType').val(aig_orderStorage.applicant.idtype),
            //update by Eren js升级的代码 20190419 start
            //$('.layui-order-form #ApplicantIdNumber').val(aig_orderStorage.applicant.idno),
            $('.layui-order-form #ApplicantIdType').closest('dl').find('#ApplicantIdNumber').val(aig_orderStorage.applicant.idno),
            //update by Eren js升级的代码 20190419 end
            $('.layui-order-form #ApplicantMobile').val(aig_orderStorage.applicant.mobile),
            $('.layui-order-form #ApplicantEmail').val(aig_orderStorage.applicant.email);
        $('.layui-order-form #ApplicantArea').val(aig_orderStorage.applicant.area);
        $('.layui-order-form .step-form .v2-radio-box ul li a').removeClass('selected') & $('.layui-order-form .step-form .v2-radio-box ul li:eq(' + (aig_orderStorage.applicant.sex == 'True' ? 0 : 1) + ') a').addClass('selected');
        //身份证联动
        disabledSexAndBirthday($('.layui-order-form #ApplicantIdType'), aig_orderStorage.applicant.idtype);

        // Update 2022.02.10 for 一生康美 Start
        $('.layui-order-form #ApplicantArea').val(aig_orderStorage.applicant.area);

        // Add by Xu Lei Start on 2019.9.3 投保人新增字段修改信息绑定
        $('.layui-order-form #ApplicantNationality').val(aig_orderStorage.applicant.nationality);
        $('.layui-order-form #ApplicantIdNumber').val(aig_orderStorage.applicant.idno),
            $('.layui-order-form #ApplicantIdNoPeriod').val(aig_orderStorage.applicant.idnoperiod);
        $('.layui-order-form #ApplicantIdNoPeriodCheck').val(aig_orderStorage.applicant.idnoperiodcheck);
        //$('.layui-order-form #ApplicantIdCard').val(aig_orderStorage.applicant.idcard);
        $('.layui-order-form input[id=ApplicantIdCard]').val(aig_orderStorage.applicant.idcard);//update by eren 20191009 微信端找不到对象
        $('.layui-order-form #ApplicantIdCardPeriod').val(aig_orderStorage.applicant.idcardperiod);
        $('.layui-order-form #ApplicantIdCardPeriodCheck').val(aig_orderStorage.applicant.idcardperiodcheck);
        $('.layui-order-form #ApplicantLiveCity').val(aig_orderStorage.applicant.livecity);
        $('.layui-order-form #ApplicantLiveAddress').val(aig_orderStorage.applicant.liveaddress);
        //$('.layui-order-form #ApplicantJobCompany').val(aig_orderStorage.applicant.jobcompany);
        $('.layui-order-form input[id=ApplicantJobCompany]').val(aig_orderStorage.applicant.jobcompany);//update by eren 20191030 微信端直接通过id找不到对象
        $('.layui-order-form #ApplicantJobCareer').val(aig_orderStorage.applicant.jobcareer);
        $('.layui-order-form #ApplicantJobIncome').val(aig_orderStorage.applicant.jobincome);
        if (aig_orderStorage.applicant.idnoperiodcheck == 'True') {
            $('.layui-order-form #ApplicantIdNoPeriodCheck').closest('dd').find('a.checkbox').addClass('selected');
            $('.layui-order-form #ApplicantIdNoPeriod').attr('datatype', '*').removeClass('Validform_error Validform_error2');
        }
        if (aig_orderStorage.applicant.idcardperiodcheck == 'True') {
            $('.layui-order-form #ApplicantIdCardPeriodCheck').closest('dd').find('a.checkbox').addClass('selected');
            $('.layui-order-form #ApplicantIdCardPeriod').attr('datatype', '*').removeClass('Validform_error Validform_error2');
        }
        // Add by Xu Lei End on 2019.9.3

        //update by meixuan 2019-09-29 
        $('.layui-order-form .idcard-info').hide();
        $('.layui-order-form .idcard-info input').attr('ignore', 'ignore');
        $('.layui-order-form #ApplicantBrithDate').removeAttr('disabled');
        $('.layui-order-form #ApplicantBrithDate').closest('dd').find('a.radio').removeClass('disabled');
        if (aig_orderStorage.applicant.nationality == '中国') {
            if (aig_orderStorage.applicant.idtype != '身份证') {
                // UP：2020.02.22
                $('.layui-order-form .idcard-info').show();
                $('.layui-order-form .idcard-info input[rel=idcard]').removeAttr('ignore');
                IDperiodpicker('.layui-order-form input[rel=idcardperiod]');
            }
            $('.layui-order-form #ApplicantBrithDate').attr('disabled', 'disabled');
            $('.layui-order-form #ApplicantBrithDate').closest('dd').find('a.radio').addClass('disabled');
        }
        //end
        //检测证件号码是否有重复
        checkApplicantDuplicate();
        //身份证自动填充性别&出生日期

        //add by eren 20191029 证件类型为身份证时才显示永久有效的框 start
        if ($('.layui-order-form #ApplicantIdType').val() == "身份证") {
            $('.layui-order-form input[id=ApplicantIdNoPeriodCheck]').parent().show();
        }
        else {
            $('.layui-order-form input[id=ApplicantIdNoPeriodCheck]').parent().hide();
        }
        //add by eren 20191029 证件类型为身份证时才显示永久有效的框 end

        // =====2019.11.1 初始化地区、职业选项
        picker_livecity();
        picker_jobcareer();
        // =====2019.11.1 初始化地区、职业选项 end

        valid();
        birthdaypicker('.layui-order-form .dtpicker_birth');
    })

    //被保人姓名失去焦点，验证证件号码信息是否重复【解决报错重复后不修改证件号码，修改姓名后即可通验证的问题】
    $(document).on('blur', '.layui-order-form #InsuredName', function (str) {
        //证件号码不为空在验证证件号码
        if ($.trim($('.layui-order-form #InsuredIdNumber').val()) != '') {
            $('.layui-order-form #InsuredIdNumber').blur();
        }
    })


    //被保人证件号码失去焦点
    $(document).on('blur', '.layui-order-form #InsuredIdNumber', function (str) {
        //update by eren 20190419 回滚js升级的代码 start
        //$(this).val($(this).val().trim());
        $('.layui-order-form #InsuredIdType').closest('dl').find('#InsuredIdNumber').val($('.layui-order-form #InsuredIdType').closest('dl').find('#InsuredIdNumber').val().trim())
        //update by eren 20190419 回滚js升级的代码 end
        $(".layui-order-form .step-form .tip-relation").hide();
        $(".layui-order-form .step-form .tip-repeatinsured").hide();
            //检验被保人是否重复 
            checkInsuredDuplicate(str);
        var v = $(this).parents(".step-form").find("input[name=InsuredIdType]").val();
        UpdateSexandBirthdayByIDNo($(this), v);
    })

    /** 被保人身份证 Input Blur*/
    $(document).on('blur', '.layui-order-form #InsuredIdCard', function () {
        $(this).val($(this).val().trim());
        $(".layui-order-form .step-form .tip-relation").hide();
        $(".layui-order-form .step-form .tip-repeatinsured").hide();
        if ($(this).val() == '') {
            $('.layui-order-form input[rel=age]').val("");
            return false;
        }
        $('.layui-order-form input[rel=age]').closest('dd').find('.radio').addClass('disabled');
        $('.layui-order-form input[rel=age]').attr("disabled", "disabled");
         //检验被保人是否重复
      
            checkInsuredDuplicate();
        
        UpdateSexandBirthdayByIDNo($(this), '身份证');
    })

    //投保人证件号码失去焦点
    $(document).on('blur', '.layui-order-form #ApplicantIdNumber', function () {
        //update by eren 20190419 回滚js升级的代码 start
        //$(this).val($(this).val().trim());
        $('.layui-order-form #ApplicantIdType').closest('dl').find('#ApplicantIdNumber').val($('.layui-order-form #ApplicantIdType').closest('dl').find('#ApplicantIdNumber').val().trim())
        //update by eren 20190419 回滚js升级的代码 end
        //检验投保人是否和被保人是否重复
        //checkApplicantDuplicate();
        var v = $(this).parents(".step-form").find("input[name=ApplicantIdType]").val()

        UpdateSexandBirthdayByIDNo($(this), v);


    })

    //投保人身份证号码失去焦点
    $(document).on('blur', '.layui-order-form #ApplicantIdCard', function () {
        //测试byHufei
        //update by eren 20190419 回滚js升级的代码 start
        //$(this).val($(this).val().trim());
        var idcard = $('.layui-order-form #ApplicantIdType').closest('dl').siblings('dl.idcard-info').find('#ApplicantIdCard');
        idcard.val(idcard.val().trim());

        //update by eren 20190419 回滚js升级的代码 end
        //检验投保人是否和被保人是否重复
        checkApplicantDuplicate();
        var v = $(this).parents(".step-form").find("input[name=ApplicantIdType]").val()

        //身份证更新 add by hufei
        var $boxscroll = $(this);
        var UUserCard = $boxscroll.val();
        //check IDno rule
        var birthdate;
        var sex;
        if (UUserCard.length == 18) {
            birthdate = UUserCard.substring(6, 10);
            birthdate = birthdate + "-" + UUserCard.substring(10, 12) + "-" + UUserCard.substring(12, 14);
            sex = parseInt(UUserCard.substr(16, 1)) % 2 == 1;

        }
        else {
            birthdate = UUserCard.substring(6, 8);
            if (birthdate > 20) {
                birthdate = "19" + birthdate;
            }
            else {
                birthdate = "20" + birthdate;
            }

            birthdate = birthdate + "-" + UUserCard.substring(8, 10) + "-" + UUserCard.substring(10, 12);
            sex = parseInt(UUserCard.substr(14, 1)) % 2 == 1;
        }
        //sex
        $boxscroll.parents(".step-form").find(".v2-radio-box ul li a").removeClass('selected') & $('.layui-order-form .step-form .v2-radio-box ul li:eq(' + (sex == true ? 0 : 1) + ') a').addClass('selected');
        sexvalue = sex == true ? "True" : "False";
        //birthday
        //update by eren 20190929 证件号校验不通过将出生日期输入框内容置空 start
        var reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
        if (reg.test(UUserCard) === false) {
            birthdate = "";
        }
        else {
            $boxscroll.parents(".step-form").find("input[name=ApplicantBrithDate]").removeClass('Validform_error');
        }
        //update by eren 20190929 证件号校验不通过将出生日期输入框内容置空 end
        $boxscroll.parents(".step-form").find("input[name=ApplicantBrithDate]").val(birthdate).attr('disabled', 'disabled');
        $boxscroll.parents(".step-form").find("input[name=ApplicantGender]").val(sexvalue).attr('disabled', 'disabled');
        $boxscroll.parents('dl').siblings('dl').find('.radio').addClass('disabled');//add by eren 20191014 性别单选框禁用
    })


    var insured = -1;
    //绑定弹窗的被保人资料到页面
    function i_insured() {
        //if ($('.layui-order-form .Validform_error').length > 0 || '' == $('.layui-order-form #InsuredName').val() || '' == $('.layui-order-form #InsuredBrithDate').val() || '' == $('.layui-order-form #InsuredIdType').val() || '' == $('.layui-order-form #InsuredIdNumber').val() || '' == $('.layui-order-form #InsuredMobile').val() || '' == $('.layui-order-form #InsuredRelation').val())
        //if ($('.layui-order-form .Validform_error').length > 0 || '' == $('.layui-order-form input[id=InsuredName]').val() || '' == $('.layui-order-form #InsuredBrithDate').val() || '' == $('.layui-order-form #InsuredIdType').val() || '' == $('.layui-order-form #InsuredIdNumber').val() || '' == $('.layui-order-form #InsuredMobile').val() || '' == $('.layui-order-form #InsuredRelation').val())
        ////update by eren 20191007 微信端直接通过id找不到对象

        // UP：2020.01.16
        //$('.layui-order-form input:visible').blur();
        $(".layui-order-form input:visible").each(function(){
            var $input = $(this);
            if($input.val().length==0)
                $input.blur();
        });
        // UP：2020.01.16 end

        if (!checkBirthday_insured()) {
            $('.layui-order-form #InsuredBrithDate').addClass("Validform_error").blur();
            return false;
        }
        if ($('.layui-order-form input[name=InsuredRelation]').val() == '请选择') {
            $('.layui-order-form input[name=InsuredRelation]').addClass('Validform_error');
            return false;
        }

        if ($('.layui-order-form dl:eq(0) span:visible').length > 0) {
            return false;
        }

        if ($('.layui-order-form input:visible.Validform_error').length > 0 || '' == $('.layui-order-form input[id=InsuredName]').val() || '' == $('.layui-order-form #InsuredBrithDate').val() || '' == $('.layui-order-form #InsuredIdType').val() || '' == $('.layui-order-form #InsuredIdNumber').val() || '' == $('.layui-order-form #InsuredMobile').val() || '' == $('.layui-order-form #InsuredRelation').val())
            return false;


        // =====2019.11.1 验证职业是否符合投保规则
        if (!checkPlan($('.layui-order-form #InsuredJobCareer').val())) {
            return false;
        }
        //if (!checkInsuredAge()) {
        //    return false;
        //}
        // =====2019.11.1 验证职业是否符合投保规则 end

        var i = -1 < insured ? insured : $('#step-insured .step-info-box .step-info').length;
        aig_orderStorage.insured[i] = {
            //update by eren 20190419 js的升级版本 start
            //'name': $('.layui-order-form #InsuredName').val().trim(),
            'name': $('.layui-order-form input[id=InsuredName]').val().trim(),//update by eren 20190930 微信端直接通过id找不到对象
            //update by eren 20190419 js的升级版本 end
            'sex': $('.layui-order-form #InsuredGender').val() == 'True' ? 'True' : 'False',
            'birthday': $('.layui-order-form #InsuredBrithDate').val(),
            'idtype': $('.layui-order-form #InsuredIdType').val(),
            //update by eren 20190419 js的升级版本 start
            'idno': $('.layui-order-form #InsuredIdType').closest('dl').find('#InsuredIdNumber').val().trim(),
            //'idno': $('.layui-order-form #InsuredIdNumber').val().trim(),
            //update by eren 20190419 js的升级版本 end
            'mobile': $('.layui-order-form #InsuredMobile').val(),
            'relation': $('.layui-order-form #InsuredRelation').val(),

            // Add by Xu Lei Start on 2019.9.3 被保人新增字段
            'nationality': $('.layui-order-form #InsuredNationality').val(),
            'idnoperiod': $('.layui-order-form #InsuredIdNoPeriod').val(),
            'idnoperiodcheck': $('.layui-order-form #InsuredIdNoPeriodCheck').val(),
            /*'idcard': $('.layui-order-form #InsuredIdCard').val(),*/
            'idcard': $('.layui-order-form #InsuredIdType').closest('dl').find('#InsuredIdNumber').val().trim(),//update by eren 20191007 微信端直接通过id找不到对象
            //'idcard': $('.layui-order-form input[id=InsuredIdCard]').val(),//update by eren 20191007 微信端直接通过id找不到对象
            'idcardperiod': $('.layui-order-form #InsuredIdCardPeriod').val(),
            'idcardperiodcheck': $('.layui-order-form #InsuredIdCardPeriodCheck').val(),
            'livecity': $('.layui-order-form #InsuredLiveCity').val(),
            'liveaddress': $('.layui-order-form #InsuredLiveAddress').val(),
            'jobcompany': $('.layui-order-form input[id=InsuredJobCompany]').val(),//update by eren 20191030 微信端找不到对象
            'jobcareer': $('.layui-order-form #InsuredJobCareer').val(),
            'jobincome': $('.layui-order-form #InsuredJobIncome').val()
            // Add by Xu Lei End on 2019.9.3
        };
        var id = '本人' == aig_orderStorage.insured[i].relation ? 'id="insured-oneself"' : '';
        //性别必须这样，拼接到里面3元运算符不能正确识别；
        var tempsex = aig_orderStorage.insured[i].sex == "True" ? "男" : "女";
        // Update by Xu Lei Start on 2019.9.3 被保险人新增字段展示
        var isshow_idcard = 1;
        if ((aig_orderStorage.insured[i].nationality == '中国' && aig_orderStorage.insured[i].idtype == '身份证') || (aig_orderStorage.insured[i].nationality != '中国')) {
            isshow_idcard = 0;
        }
        var inncomme = aig_orderStorage.insured[i].jobincome;
        if (inncomme.indexOf('以上') > 0) {
            inncomme = '50万以上/年';
        } else if (inncomme) {
            inncomme += '万/年';
        }
        //Update by Xu Lei at 2020.10.30 for 添加百万医疗DTC Start
        //update by lisa 202020108 GBA 只有一个被保人，隐藏删除被保人按钮
        var IsShowDelBtbHtml = "";
        var ProductCode = $("input[name='ProductCode']").val();
        // Update 2021.01.05 for 更新一生康美DTC Start
        // if (ProductCode == "150331" || ProductCode == "180301" || ProductCode == "18030101") {
        //     IsShowDelBtbHtml = 'style = "display:none !important;margin:1.25rem auto;';
        // }
        if (ProductCode == "150331" || ProductCode == "18030101") {
            IsShowDelBtbHtml = 'style = "display:none !important;margin:1.25rem auto;';
        }
        // Update 2021.01.05 for 更新一生康美DTC End
        //Update by Xu Lei at 2020.10.30 for 添加百万医疗DTC End
        //Update by Xu Lei at 2020.11.03 for 添加百万医疗DTC Start
        if ($("input[name='ProductCode']").val() == '180301' || $("input[name='ProductCode']").val() == '180302' || $("input[name='ProductCode']").val() == '18030101') {
            var html = '<div class="step-info" ' + id + '>\n' +
                '<ul>\n' +
                '<li><label>与投保人关系：</label>' + aig_orderStorage.insured[i].relation + '<input value="' + aig_orderStorage.insured[i].relation + '" name="InsuredPersons[' + i + '].RELATION_CODE" type="hidden" disabled="disabled"></li>\n' +
                '<li><label>被保险人姓名：</label>' + aig_orderStorage.insured[i].name + '<input value="' + aig_orderStorage.insured[i].name + '" name="InsuredPersons[' + i + '].NAME" type="hidden" disabled="disabled" ></li>\n' +
                '<li><label>性别：</label>' + tempsex + '<input value="' + aig_orderStorage.insured[i].sex + '" name="InsuredPersons[' + i + '].GENDER" type="hidden" disabled="disabled"></li>\n' +
                '<li><label>国籍（地区）：</label>' + aig_orderStorage.insured[i].nationality + '<input value="' + aig_orderStorage.insured[i].nationality + '" name="InsuredPersons[' + i + '].NATIONALITY" type="hidden" disabled="disabled"></li>\n' +
                '<li><label>出生日期：</label>' + aig_orderStorage.insured[i].birthday + '<input value="' + aig_orderStorage.insured[i].birthday + '" name="InsuredPersons[' + i + '].BIRTH_DATE"  type="hidden" disabled="disabled"> </li>\n' +
                '<li><label>身份证：</label>' + '<label style="display:none;">' + aig_orderStorage.insured[i].idtype + '</label>' + aig_orderStorage.insured[i].idno + '<input value="' + aig_orderStorage.insured[i].idtype + '" name="InsuredPersons[' + i + '].ID_TYPE_ID" type="hidden" disabled="disabled">  <input value="' + aig_orderStorage.insured[i].idno + '" name="InsuredPersons[' + i + '].ID_NO" type="hidden" disabled="disabled"></li>\n' +
                '<li style="' + (!aig_orderStorage.insured[i].idnoperiod.length ? 'display:none' : '') + '"><label>身份证有效期至：</label>' + aig_orderStorage.insured[i].idnoperiod + '<input value="' + aig_orderStorage.insured[i].idnoperiod + '" name="InsuredPersons[' + i + '].ID_NO_PERIOD" type="hidden" disabled="disabled">\n' +
                '<li style="' + (!isshow_idcard ? 'display:none' : '') + '"><label>身份证：</label>' + aig_orderStorage.insured[i].idcard + '<input value="' + aig_orderStorage.insured[i].idcard + '" name="InsuredPersons[' + i + '].ID_CARD" type="hidden" disabled="disabled">\n' +
                '<li style="' + (!isshow_idcard || !aig_orderStorage.insured[i].idcardperiod.length ? 'display:none' : '') + '"><label>身份证有效期至：</label>' + aig_orderStorage.insured[i].idcardperiod + '<input value="' + aig_orderStorage.insured[i].idcardperiod + '" name="InsuredPersons[' + i + '].ID_CARD_PERIOD" type="hidden" disabled="disabled">\n' +
                '<li><label>手机号码：</label>' + aig_orderStorage.insured[i].mobile + '<input value="' + aig_orderStorage.insured[i].mobile + '" name="InsuredPersons[' + i + '].MOBILE" type="hidden" disabled="disabled"></li>\n' +
                // update by meixuan 2023.10.20
                '<li style="' + (!aig_orderStorage.insured[i].livecity.length ? 'display:none' : '') + '" class="address"><label>所在地：</label><span>' + aig_orderStorage.insured[i].livecity + '</span><input value="' + aig_orderStorage.insured[i].livecity + '" name="InsuredPersons[' + i + '].LIVE_CITY" type="hidden" disabled="disabled"></li>\n' +
                //'<li style="' + (!aig_orderStorage.insured[i].livecity.length ? 'display:none' : '') + '"><label>居住地址：</label>' + aig_orderStorage.insured[i].livecity + '<input value="' + aig_orderStorage.insured[i].livecity + '" name="InsuredPersons[' + i + '].LIVE_CITY" type="hidden" disabled="disabled"></li>\n' +
                '<li style="' + (!aig_orderStorage.insured[i].liveaddress.length ? 'display:none' : '') + '" class="address"><label>详细地址：</label><span>' + aig_orderStorage.insured[i].liveaddress + '</span><input value="' + aig_orderStorage.insured[i].liveaddress + '" name="InsuredPersons[' + i + '].LIVE_ADDRESS" type="hidden" disabled="disabled"></li>\n' +
                //'<li class="address" style="' + (!aig_orderStorage.insured[i].jobcompany.length ? 'display:none' : '') + '"><label>工作单位：</label><span>' + aig_orderStorage.insured[i].jobcompany + '</span><input value="' + aig_orderStorage.insured[i].jobcompany + '" name="InsuredPersons[' + i + '].JOB_COMPANY" type="hidden" disabled="disabled"></li>\n' +
                '<li style="' + (!aig_orderStorage.insured[i].jobcareer.length ? 'display:none' : '') + '"><label>职业与类别：</label>' + aig_orderStorage.insured[i].jobcareer + '<input value="' + aig_orderStorage.insured[i].jobcareer + '" name="InsuredPersons[' + i + '].JOB_CAREER" type="hidden" disabled="disabled"></li>\n' +
                '<li class="address" style="' + (!aig_orderStorage.insured[i].jobcompany.length ? 'display:none' : '') + '"><label>工作单位名称：</label><span>' + aig_orderStorage.insured[i].jobcompany + '</span><input value="' + aig_orderStorage.insured[i].jobcompany + '" name="InsuredPersons[' + i + '].JOB_COMPANY" type="hidden" disabled="disabled"></li>\n' +
                '<li style="' + (!aig_orderStorage.insured[i].jobincome.length ? 'display:none' : '') + '"><label>收入：</label>' + inncomme + '<input value="' + aig_orderStorage.insured[i].jobincome + '" name="InsuredPersons[' + i + '].JOB_INCOME" type="hidden" disabled="disabled"></li>\n' +
                '</ul>\n' +
                '<div class="btn-box"><a href="javascript:;" class="btn btn-add-insured-del" ' + IsShowDelBtbHtml + ' currentIndex="' + i + '" data-name="' + aig_orderStorage.insured[i].name + '">删除</a><a href="javascript:;" class="btn btn-add-insured-edit">修改</a></div>\n' +
                '</div>';
        } else if (ProductCode == "020606"||ProductCode == "0206062")

        {
                var html = '<div class="step-info" ' + id + '>\n' +
                    '<ul>\n' +
                    '<li><label>与投保人关系：</label>' + aig_orderStorage.insured[i].relation + '<input value="' + aig_orderStorage.insured[i].relation + '" name="InsuredPersons[' + i + '].RELATION_CODE" type="hidden" disabled="disabled"></li>\n' +
                    '<li><label>被保险人姓名：</label>' + aig_orderStorage.insured[i].name + '<input value="' + aig_orderStorage.insured[i].name + '" name="InsuredPersons[' + i + '].NAME" type="hidden" disabled="disabled" ></li>\n' +
                    '<li><label>性别：</label>' + tempsex + '<input value="' + aig_orderStorage.insured[i].sex + '" name="InsuredPersons[' + i + '].GENDER" type="hidden" disabled="disabled"></li>\n' +
                    '<li><label>国籍（地区）：</label>' + aig_orderStorage.insured[i].nationality + '<input value="' + aig_orderStorage.insured[i].nationality + '" name="InsuredPersons[' + i + '].NATIONALITY" type="hidden" disabled="disabled"></li>\n' +
                    '<li><label>出生日期：</label>' + aig_orderStorage.insured[i].birthday + '<input value="' + aig_orderStorage.insured[i].birthday + '" name="InsuredPersons[' + i + '].BIRTH_DATE"  type="hidden" disabled="disabled"> </li>\n' +
                    '<li><label>证件信息：</label>' + aig_orderStorage.insured[i].idtype + '-' + aig_orderStorage.insured[i].idno + '<input value="' + aig_orderStorage.insured[i].idtype + '" name="InsuredPersons[' + i + '].ID_TYPE_ID" type="hidden" disabled="disabled">  <input value="' + aig_orderStorage.insured[i].idno + '" name="InsuredPersons[' + i + '].ID_NO" type="hidden" disabled="disabled"></li>\n' +
                    '<li style="' + (!aig_orderStorage.insured[i].idnoperiod.length ? 'display:none' : '') + '"><label>证件有效期至：</label>' + aig_orderStorage.insured[i].idnoperiod + '<input value="' + aig_orderStorage.insured[i].idnoperiod + '" name="InsuredPersons[' + i + '].ID_NO_PERIOD" type="hidden" disabled="disabled">\n' +
                    '<li style="' + (!isshow_idcard ? 'display:none' : '') + '"><label>身份证：</label>' + aig_orderStorage.insured[i].idcard + '<input value="' + aig_orderStorage.insured[i].idcard + '" name="InsuredPersons[' + i + '].ID_CARD" type="hidden" disabled="disabled">\n' +
                    '<li style="' + (!isshow_idcard || !aig_orderStorage.insured[i].idcardperiod.length ? 'display:none' : '') + '"><label>身份证有效期至：</label>' + aig_orderStorage.insured[i].idcardperiod + '<input value="' + aig_orderStorage.insured[i].idcardperiod + '" name="InsuredPersons[' + i + '].ID_CARD_PERIOD" type="hidden" disabled="disabled">\n' +
                    '<li><label>手机号码：</label>' + aig_orderStorage.insured[i].mobile + '<input value="' + aig_orderStorage.insured[i].mobile + '" name="InsuredPersons[' + i + '].MOBILE" type="hidden" disabled="disabled"></li>\n' +
                    // update by meixuan 2023.10.20
                    '<li style="' + (!aig_orderStorage.insured[i].livecity.length ? 'display:none' : '') + '" class="address"><label>所在地：</label><span>' + aig_orderStorage.insured[i].livecity + '</span><input value="' + aig_orderStorage.insured[i].livecity + '" name="InsuredPersons[' + i + '].LIVE_CITY" type="hidden" disabled="disabled"></li>\n' +
                    //'<li style="' + (!aig_orderStorage.insured[i].livecity.length ? 'display:none' : '') + '"><label>居住地址：</label>' + aig_orderStorage.insured[i].livecity + '<input value="' + aig_orderStorage.insured[i].livecity + '" name="InsuredPersons[' + i + '].LIVE_CITY" type="hidden" disabled="disabled"></li>\n' +
                    '<li style="' + (!aig_orderStorage.insured[i].liveaddress.length ? 'display:none' : '') + '" class="address"><label>详细地址：</label><span>' + aig_orderStorage.insured[i].liveaddress + '</span><input value="' + aig_orderStorage.insured[i].liveaddress + '" name="InsuredPersons[' + i + '].LIVE_ADDRESS" type="hidden" disabled="disabled"></li>\n' +
                    //'<li class="address" style="' + (!aig_orderStorage.insured[i].jobcompany.length ? 'display:none' : '') + '"><label>工作单位：</label><span>' + aig_orderStorage.insured[i].jobcompany + '</span><input value="' + aig_orderStorage.insured[i].jobcompany + '" name="InsuredPersons[' + i + '].JOB_COMPANY" type="hidden" disabled="disabled"></li>\n' +
                    '<li style="' + (!aig_orderStorage.insured[i].jobcareer.length ? 'display:none' : '') + '"><label>职业与类别：</label>' + aig_orderStorage.insured[i].jobcareer + '<input value="' + aig_orderStorage.insured[i].jobcareer + '" name="InsuredPersons[' + i + '].JOB_CAREER" type="hidden" disabled="disabled"></li>\n' +
                    '<li class="address" style="' + (!aig_orderStorage.insured[i].jobcompany.length ? 'display:none' : '') + '"><label>工作单位名称：</label><span>' + aig_orderStorage.insured[i].jobcompany + '</span><input value="' + aig_orderStorage.insured[i].jobcompany + '" name="InsuredPersons[' + i + '].JOB_COMPANY" type="hidden" disabled="disabled"></li>\n' +
                    '<li style="' + (!aig_orderStorage.insured[i].jobincome.length ? 'display:none' : '') + '"><label>收入：</label>' + inncomme + '<input value="' + aig_orderStorage.insured[i].jobincome + '" name="InsuredPersons[' + i + '].JOB_INCOME" type="hidden" disabled="disabled"></li>\n' +
                    '</ul>\n' +
                    '<div class="btn-box"><a href="javascript:;" class="btn btn-add-insured-edit">修改</a></div>\n' +
                    '</div>';
        }
        else {
            var html = '<div class="step-info" ' + id + '>\n' +
                '<ul>\n' +
                '<li><label>与投保人关系：</label>' + aig_orderStorage.insured[i].relation + '<input value="' + aig_orderStorage.insured[i].relation + '" name="InsuredPersons[' + i + '].RELATION_CODE" type="hidden" disabled="disabled"></li>\n' +
                '<li><label>被保险人姓名：</label>' + aig_orderStorage.insured[i].name + '<input value="' + aig_orderStorage.insured[i].name + '" name="InsuredPersons[' + i + '].NAME" type="hidden" disabled="disabled" ></li>\n' +
                '<li><label>性别：</label>' + tempsex + '<input value="' + aig_orderStorage.insured[i].sex + '" name="InsuredPersons[' + i + '].GENDER" type="hidden" disabled="disabled"></li>\n' +
                '<li><label>国籍（地区）：</label>' + aig_orderStorage.insured[i].nationality + '<input value="' + aig_orderStorage.insured[i].nationality + '" name="InsuredPersons[' + i + '].NATIONALITY" type="hidden" disabled="disabled"></li>\n' +
                '<li><label>出生日期：</label>' + aig_orderStorage.insured[i].birthday + '<input value="' + aig_orderStorage.insured[i].birthday + '" name="InsuredPersons[' + i + '].BIRTH_DATE"  type="hidden" disabled="disabled"> </li>\n' +
                '<li><label>证件信息：</label>' + aig_orderStorage.insured[i].idtype + '-' + aig_orderStorage.insured[i].idno + '<input value="' + aig_orderStorage.insured[i].idtype + '" name="InsuredPersons[' + i + '].ID_TYPE_ID" type="hidden" disabled="disabled">  <input value="' + aig_orderStorage.insured[i].idno + '" name="InsuredPersons[' + i + '].ID_NO" type="hidden" disabled="disabled"></li>\n' +
                '<li style="' + (!aig_orderStorage.insured[i].idnoperiod.length ? 'display:none' : '') + '"><label>证件有效期至：</label>' + aig_orderStorage.insured[i].idnoperiod + '<input value="' + aig_orderStorage.insured[i].idnoperiod + '" name="InsuredPersons[' + i + '].ID_NO_PERIOD" type="hidden" disabled="disabled">\n' +
                '<li style="' + (!isshow_idcard ? 'display:none' : '') + '"><label>身份证：</label>' + aig_orderStorage.insured[i].idcard + '<input value="' + aig_orderStorage.insured[i].idcard + '" name="InsuredPersons[' + i + '].ID_CARD" type="hidden" disabled="disabled">\n' +
                '<li style="' + (!isshow_idcard || !aig_orderStorage.insured[i].idcardperiod.length ? 'display:none' : '') + '"><label>身份证有效期至：</label>' + aig_orderStorage.insured[i].idcardperiod + '<input value="' + aig_orderStorage.insured[i].idcardperiod + '" name="InsuredPersons[' + i + '].ID_CARD_PERIOD" type="hidden" disabled="disabled">\n' +
                '<li><label>手机号码：</label>' + aig_orderStorage.insured[i].mobile + '<input value="' + aig_orderStorage.insured[i].mobile + '" name="InsuredPersons[' + i + '].MOBILE" type="hidden" disabled="disabled"></li>\n' +
                // update by meixuan 2023.10.20
                '<li style="' + (!aig_orderStorage.insured[i].livecity.length ? 'display:none' : '') + '" class="address"><label>所在地：</label><span>' + aig_orderStorage.insured[i].livecity + '</span><input value="' + aig_orderStorage.insured[i].livecity + '" name="InsuredPersons[' + i + '].LIVE_CITY" type="hidden" disabled="disabled"></li>\n' +
                //'<li style="' + (!aig_orderStorage.insured[i].livecity.length ? 'display:none' : '') + '"><label>居住地址：</label>' + aig_orderStorage.insured[i].livecity + '<input value="' + aig_orderStorage.insured[i].livecity + '" name="InsuredPersons[' + i + '].LIVE_CITY" type="hidden" disabled="disabled"></li>\n' +
                '<li style="' + (!aig_orderStorage.insured[i].liveaddress.length ? 'display:none' : '') + '" class="address"><label>详细地址：</label><span>' + aig_orderStorage.insured[i].liveaddress + '</span><input value="' + aig_orderStorage.insured[i].liveaddress + '" name="InsuredPersons[' + i + '].LIVE_ADDRESS" type="hidden" disabled="disabled"></li>\n' +
                //'<li class="address" style="' + (!aig_orderStorage.insured[i].jobcompany.length ? 'display:none' : '') + '"><label>工作单位：</label><span>' + aig_orderStorage.insured[i].jobcompany + '</span><input value="' + aig_orderStorage.insured[i].jobcompany + '" name="InsuredPersons[' + i + '].JOB_COMPANY" type="hidden" disabled="disabled"></li>\n' +
                '<li style="' + (!aig_orderStorage.insured[i].jobcareer.length ? 'display:none' : '') + '"><label>职业与类别：</label>' + aig_orderStorage.insured[i].jobcareer + '<input value="' + aig_orderStorage.insured[i].jobcareer + '" name="InsuredPersons[' + i + '].JOB_CAREER" type="hidden" disabled="disabled"></li>\n' +
                '<li class="address" style="' + (!aig_orderStorage.insured[i].jobcompany.length ? 'display:none' : '') + '"><label>工作单位名称：</label><span>' + aig_orderStorage.insured[i].jobcompany + '</span><input value="' + aig_orderStorage.insured[i].jobcompany + '" name="InsuredPersons[' + i + '].JOB_COMPANY" type="hidden" disabled="disabled"></li>\n' +
                '<li style="' + (!aig_orderStorage.insured[i].jobincome.length ? 'display:none' : '') + '"><label>收入：</label>' + inncomme + '<input value="' + aig_orderStorage.insured[i].jobincome + '" name="InsuredPersons[' + i + '].JOB_INCOME" type="hidden" disabled="disabled"></li>\n' +
                '</ul>\n' +
                '<div class="btn-box"><a href="javascript:;" class="btn btn-add-insured-del" ' + IsShowDelBtbHtml + ' currentIndex="' + i + '" data-name="' + aig_orderStorage.insured[i].name + '">删除</a><a href="javascript:;" class="btn btn-add-insured-edit">修改</a></div>\n' +
                '</div>';
        }
        //Update by Xu Lei at 2020.11.03 for 添加百万医疗DTC End
        // Update by Xu Lei End on 2019.9.3
        if (-1 < insured)
            $('#step-insured .step-info-box .step-info').eq(insured).prop('outerHTML', html);
        else
            $('#step-insured .step-info-box').append(html);
        // console.log(aig_orderStorage.insured);
        console.log("绑定当前被保人到页面成功");
        //Update by Amy at 2021.06.01 for 添加宝贝无忧 Start
        if (ProductCode == "020606"||ProductCode == "0206062") {
            // 宝贝无忧 2021.05.20 删除添加被保险人按钮
            $('#step-insured .btn-add-insured').remove();
        }
            //Update by Amy at 2021.06.01 for 添加宝贝无忧 Ends
        return true;
    }
    //被保险人新增
    $(document).on('click', '.btn-add-insured', function () {
        //判断是否超出最大被保人人数限制
        var maxInsuredCount = parseInt($("#Max_Insured_Count").val());
        var CurrentInsuredCount = $('#step-insured .step-info-box .step-info').length;
        if (CurrentInsuredCount >= maxInsuredCount) {
            var msg = "被保险人个数不能超过最大限制：" + maxInsuredCount + "人";
            layer.open({
                className: 'layui-order-msg'
                , content: msg
                , skin: 'msg'
                , time: 2
            });
            return false;
        }

        ClearApplicantErrormsg("Insured");
        //var CurrentInsuredCount = $('#step-insured .step-info-box .step-info').length;
        //$("#editstatus").attr("name", CurrentInsuredCount+1);
        insured = -1;
        var $this = $(this);
        //判断投保人信息是否录入
        if (!$('#step-applicant .step-info-box .step-info').is(":visible")) {
            $('#step-applicant .btn-add-applicant').next('p').show();
            return false;
        }
        //异步询价方法的调用
        // QuotoPriceMethod(true);
        layer.open({
            className: 'layui-order-form'
            , title: [
                '<a href="javascript:;" class="layui-order-close"></a>被保险人信息',
                'text-align:center !important;text-indent:0;background-color:#fff;'
            ]
            , type: 1
            , content: '<div class="v2-order-step">' + $('#step-insured .step-form').prop("outerHTML") + '</div>'
            , anim: 'right'
            , style: 'position:fixed; left:0; top:0; width:100%; height:100%; border: none; -webkit-animation-duration: .5s; animation-duration: .5s;'
            , btn: '确认'
            , yes: function (index) {

                //if ($('.layui-order-form #InsuredBrithDate').hasClass('Validform_error')) {
                //    msglayer = layer.open({
                //        className: 'layui-order-tip'
                //        , title: [
                //            '提示<a href="javascript:;" class="layui-msg-close"></a>',
                //            'background-color:#f1f9ff;color:#fff;border-radius:0;color:#333;font-size:.6rem;height:1.75rem;line-height:1.75rem;'
                //        ]
                //        , anim: 'up'
                //        , content: '<p style="font-size:.6rem;color:#333;text-align:center;padding:1.25rem 0;"><img src="/MImg/order_ah/icon-order-msg-error.png" style="display:block;width:2.1rem;margin:0 auto 0.6rem;">保单生效之日，被保险人年龄须为18-55周岁<br><span style="color:#fe8a01;">被保险人年龄不在投保范围</span></p>'
                //    })
                //}

                //如果页面上提示重现投被保关系，不继续提交验证
                if (!$(".layui-order-form .step-form").find(".tip-relation").is(":hidden")) {
                    return false;
                }
                //如果页面上提示被保人重复，不继续提交验证
                if (!$(".layui-order-form .step-form").find(".tip-repeatinsured").is(":hidden")) {
                    return false;
                }
                var re = i_insured();
                if (!re) {
                    return false;
                }
                //Update by Xu Lei at 2020.10.30 for 添加百万医疗DTC Start
                //update by lisa 20200108 GBA 只有一个被保人，确认填写第一个被保人后需要隐藏新增被保人按钮
                // $this.next('p').hide(), $this, layer.closeAll();
               
                var ProductCode = $("input[name='ProductCode']").val();

                // Update 2021.01.05 for 更新一生康美DTC Start
                // if (ProductCode == "150331" || ProductCode == "180301" || ProductCode == "18030101") {
                //     $this.hide();
                // }
                if (ProductCode == "150331" || ProductCode == "18030101") {
                    $this.hide();
                }
                // Update 2021.01.05 for 更新一生康美DTC End

                $this.next('p').hide(), $this, layer.closeAll();
               // 
                //Update by Xu Lei at 2020.10.30 for 添加百万医疗DTC End
                $('body').removeClass('layer-board');
                if ($('#step-insured .btn-add-insured').offset() != undefined) {
                    $body.animate({
                        scrollTop: $('#step-insured .btn-add-insured').offset().top - 335
                    }, 1000);
                }

                // 被保险人下标再整理
                RefreshInputAttribute("itemAdd");


                $("#IsQuotoPrice").val("1");

                // Add Start by Kevin 2018/11/28 Hotfix_UpliftGridSumDissector 更新国双eTravel检测代码
                //当用户完成被保人信息填写并确认时
                 _gsq.push(["track", "c_interact", { c_page_cate: "保单页", c_botton_cate: "保单页信息填写", c_botton_loc: "投保人信息-确认", c_button_name: "投保人", c_botton_url: "-", c_pro_name: $("#productName").val() }]);
                //alert("被保人信息-确认" + $("#productName").val() + "-" + (($("#PartnerCode").val() == "wechat") ? "WeChat端" : "Mob端"));
                // Add End by Kevin 2018/11/28 Hotfix_UpliftGridSumDissector 更新国双eTravel检测代码

                // Update Start by Kevin 2019/01/21 Hotfix_AddAdobeInspector etravel的购买页面增加ADOBE的监测代码和检测数据PC，WAP，WECHAT端
                UpdateAdobeInspector("9", "被保人信息-确认");
                console.log(digitalData);
                // Update End by Kevin 2019/01/21 Hotfix_AddAdobeInspector etravel的购买页面增加ADOBE的监测代码和检测数据PC，WAP，WECHAT端

            }
        });
        $('body').addClass('layer-board');
        $('.layui-order-form input').removeAttr('ignore');

        // Add by Xu Lei Start on 2019.9.3 非必填项增加ignore属性
        $('.layui-order-form input[data-ignore]').attr('ignore', 'ignore');
        IDperiodpicker('.layui-order-form input[rel=idnoperiod]');
        //new MultiPicker({
        //    input: 'InsuredLiveCity',//点击触发插件的input框的id
        //    container: 'targetContainer',//插件插入的容器id
        //    jsonData: $city,
        //    success: function (arr) {
        //        $('.layui-order-form #InsuredLiveCity').val(arr[0].value +'/'+ arr[1].value).blur();
        //    }//回调
        //});
        // Add by Xu Lei End on 2019.9.3
        $('.layui-order-form input[rel=nationality]').val('中国');
        $('.layui-order-form input[rel=age]').closest('dd').find('.radio').addClass('disabled');
        $('.layui-order-form input[rel=age]').attr("disabled", "disabled");

        // =====2019.11.1 初始化地区、职业选项
        picker_livecity();
        picker_jobcareer();
        // =====2019.11.1 初始化地区、职业选项 end

        valid();
        birthdaypicker('.layui-order-form .dtpicker_birth');

    })

    //被保险人修改
    $(document).on('click', '.btn-add-insured-edit', function () {

        //_gsq.push(["T", "GWD-002498", "trackEvent", "被保人信息", "编辑", location.pathname]);

        ClearApplicantErrormsg("Insured");
        // $('.layui-order-form input').removeClass('Validform_error');
        $("#editstatus").val("true");
        $("#editstatus").attr("name", $(this).parents(".step-info").index());
        var distance = $(document).scrollTop();
        var $this = $(this);
        var i = $this.closest('.step-info').index();
        // alert("insured:" + i);
        //alert($('#step-insured .step-form').prop("outerHTML"));
        insured = i;
        layer.open({
            className: 'layui-order-form'
            , title: [
                '<a href="javascript:;" class="layui-order-close"></a>被保险人信息',
                'text-align:center !important;text-indent:0;background-color:#fff;'
            ]
            , type: 1
            , content: '<div class="v2-order-step">' + $('#step-insured .step-form').prop("outerHTML") + '</div>'
            , anim: 'right'
            , style: 'position:fixed; left:0; top:0; width:100%; height:100%; border: none; -webkit-animation-duration: .5s; animation-duration: .5s;',
            btn: '确认'
            , yes: function (index) {
                //如果页面上提示重现投被保关系，不继续提交验证
                if (!$(".layui-order-form .step-form").find(".tip-relation").is(":hidden")) {
                    return false;
                }
                //如果页面上提示被保人重复，不继续提交验证
                if (!$(".layui-order-form .step-form").find(".tip-repeatinsured").is(":hidden")) {
                    return false;
                }
                var re = i_insured();
                if (!re) {
                    return false;
                }

                //Update by Xu Lei at 2020.10.30 for 添加百万医疗DTC Start
                if ($("input[name='ProductCode']").val() == "150331" || $("input[name='ProductCode']").val() == "180301" || $("input[name='ProductCode']").val() == "180302" || $("input[name='ProductCode']").val() == "18030101") {
                    $this.hide();
                }
                //Update by Xu Lei at 2020.10.30 for 添加百万医疗DTC End

                layer.closeAll();
                $('body').removeClass('layer-board');
                $body.animate({
                    scrollTop: distance
                }, 1000);

                // 被保险人下标再整理
                RefreshInputAttribute("itemAdd");

                $("#IsQuotoPrice").val("1");

                // Add Start by Kevin 2018/11/28 Hotfix_UpliftGridSumDissector 更新国双eTravel检测代码
                //当用户完成被保人信息填写并确认时
                 _gsq.push(["track", "c_interact", { c_page_cate: "保单页", c_botton_cate: "保单页信息填写", c_botton_loc: "投保人信息-确认", c_button_name: "投保人", c_botton_url: "-", c_pro_name: $("#productName").val() }]);
                //alert("被保人信息-确认" + $("#productName").val() + "-" + (($("#PartnerCode").val() == "wechat") ? "WeChat端" : "Mob端"));
                // Add End by Kevin 2018/11/28 Hotfix_UpliftGridSumDissector 更新国双eTravel检测代码

                // Update Start by Kevin 2019/01/21 Hotfix_AddAdobeInspector etravel的购买页面增加ADOBE的监测代码和检测数据PC，WAP，WECHAT端
                UpdateAdobeInspector("9", "被保人信息-确认");
                console.log(digitalData);
                // Update End by Kevin 2019/01/21 Hotfix_AddAdobeInspector etravel的购买页面增加ADOBE的监测代码和检测数据PC，WAP，WECHAT端

            }
        });
        ClearApplicantErrormsg("Insured");
        $('body').addClass('layer-board');
        $('.layui-order-form input').removeAttr('ignore');

        // Add by Xu Lei Start on 2019.9.3
        $('.layui-order-form input[data-ignore]').attr('ignore', 'ignore');
        IDperiodpicker('.layui-order-form input[rel=idnoperiod]');
        //new MultiPicker({
        //    input: 'InsuredLiveCity',//点击触发插件的input框的id
        //    container: 'targetContainer',//插件插入的容器id
        //    jsonData: $city,
        //    success: function (arr) {
        //        $('.layui-order-form #InsuredLiveCity').val(arr[0].value +'/'+ arr[1].value).blur();
        //    }//回调
        //});
        // Add by Xu Lei End on 2019.9.3 

        //绑定当前编辑的被保人信息到弹窗上去
        //$('.layui-order-form #InsuredName').val(aig_orderStorage.insured[i].name),
        $('.layui-order-form input[id=InsuredName]').val(aig_orderStorage.insured[i].name),//update by eren 20191007 微信端直接通过id找不到对象
            $('.layui-order-form #InsuredGender').val('True' == aig_orderStorage.insured[i].sex ? 'True' : 'False'),
            //$('.layui-order-form #InsuredBrithDate').val(aig_orderStorage.insured[i].birthday),//update by eren 将生日放到最后赋值，解决生日填充后被置空
            $('.layui-order-form #InsuredIdType').val(aig_orderStorage.insured[i].idtype),
            $('.layui-order-form #InsuredIdType').closest('dl').find('#InsuredIdNumber').val(aig_orderStorage.insured[i].idno),
            //$('.layui-order-form #InsuredIdNumber').val(aig_orderStorage.insured[i].idno),
            $('.layui-order-form #InsuredMobile').val(aig_orderStorage.insured[i].mobile),
            $('.layui-order-form #InsuredRelation').val(aig_orderStorage.insured[i].relation);
        if (aig_orderStorage.insured[i].relation == '本人') {
            $('.layui-order-form #InsuredRelation').closest('dd').next('dd').show();
            $('.layui-order-form .step-form input, .layui-order-form .step-form select').attr('disabled', 'disabled').blur();
            $('.layui-order-form ul li a').addClass('disabled');
            $('.layui-order-form #InsuredRelation').removeAttr('disabled'); $('.layui-order-form #InsuredRelation').siblings('select').removeAttr('disabled');
            //update by qufeng 2023/11/24 选择本人禁止选择所在地
            $('.layui-order-form #InsuredLiveCity').css("pointer-events", "none");// 居住地址

        } else {
            $('.layui-order-form #InsuredLiveCity').css("pointer-events", "auto");// 居住地址
        }


        if (aig_orderStorage.insured[i].nationality == '中国' && aig_orderStorage.insured[i].nationality != '身份证') {
            $('.layui-order-form .idcard-info').show();
            // UP：2020.02.22
            $('.layui-order-form .idcard-info input[rel=idcard]').removeAttr('ignore');
        }

        $('.layui-order-form .step-form .v2-radio-box ul li a').removeClass('selected') & $('.layui-order-form .step-form .v2-radio-box ul li:eq(' + (aig_orderStorage.insured[i].sex == 'True' ? 0 : 1) + ') a').addClass('selected');

        //身份证联动
        disabledSexAndBirthday($('.layui-order-form #InsuredIdType'), aig_orderStorage.insured[i].idtype);

        $('.layui-order-form #InsuredBrithDate').val(aig_orderStorage.insured[i].birthday).blur();//add by eren 将生日放到最后赋值，解决生日填充后被置空

        // Add by Xu Lei Start on 2019.9.3 被保险人新增字段修改信息绑定
        $('.layui-order-form #InsuredNationality').val(aig_orderStorage.insured[i].nationality);
        $('.layui-order-form #InsuredIdType').closest('dl').find('#InsuredIdNumber').val(aig_orderStorage.insured[i].idno).removeClass('Validform_error');
        $('.layui-order-form #InsuredIdNoPeriod').val(aig_orderStorage.insured[i].idnoperiod).removeClass('Validform_error');
        $('.layui-order-form #InsuredIdNoPeriodCheck').val(aig_orderStorage.insured[i].idnoperiodcheck);
        //$('.layui-order-form #InsuredIdCard').val(aig_orderStorage.insured[i].idcard).removeClass('Validform_error');
        $('.layui-order-form input[id=InsuredIdCard]').val(aig_orderStorage.insured[i].idcard).removeClass('Validform_error');//update by eren 20191007 微信端直接通过id找不到对象
        $('.layui-order-form #InsuredIdCardPeriod').val(aig_orderStorage.insured[i].idcardperiod);
        $('.layui-order-form #InsuredIdCardPeriodCheck').val(aig_orderStorage.insured[i].idcardperiodcheck);
        $('.layui-order-form #InsuredLiveCity').val(aig_orderStorage.insured[i].livecity);
        $('.layui-order-form #InsuredLiveAddress').val(aig_orderStorage.insured[i].liveaddress);
        $('.layui-order-form input[id=InsuredJobCompany]').val(aig_orderStorage.insured[i].jobcompany);//update by eren 20191030 微信端找不到对象
        $('.layui-order-form #InsuredJobCareer').val(aig_orderStorage.insured[i].jobcareer);
        $('.layui-order-form #InsuredJobIncome').val(aig_orderStorage.insured[i].jobincome);

        if (aig_orderStorage.insured[i].idnoperiodcheck == 'True') {
            $('.layui-order-form #InsuredIdNoPeriodCheck').closest('dd').find('a.checkbox').addClass('selected').attr('disabled', 'disabled');
            $('.layui-order-form #InsuredIdNoPeriod').attr('datatype', '*').removeClass('Validform_error Validform_error2');
        }
        if (aig_orderStorage.insured[i].idcardperiodcheck == 'True') {
            $('.layui-order-form #InsuredIdCardPeriodCheck').closest('dd').find('a.checkbox').addClass('selected').attr('disabled', 'disabled');
            $('.layui-order-form #InsuredIdCardPeriod').attr('datatype', 'd').removeClass('Validform_error Validform_error2');
        }
        // Add by Xu Lei End on 2019.9.3

        //add by eren 国籍（地区）为中国禁用生日跟性别控件
        if (aig_orderStorage.insured[i].nationality == '中国') {
            $('.layui-order-form #InsuredBrithDate').attr('disabled', 'disabled');
            $('.layui-order-form #InsuredBrithDate').closest('dd').find('a.radio').addClass('disabled');
        }

        //add by eren 20191029 证件类型为身份证时才显示永久有效的框 start
        if ($('.layui-order-form #InsuredIdType').val() == "身份证") {
            $('.layui-order-form input[id=InsuredIdNoPeriodCheck]').parent().show();
        }
        else {
            $('.layui-order-form input[id=InsuredIdNoPeriodCheck]').parent().hide();
        }
        //add by eren 20191029 证件类型为身份证时才显示永久有效的框 end

        // =====2019.11.1 初始化地区、职业选项
        picker_livecity();
        picker_jobcareer();
        // =====2019.11.1 初始化地区、职业选项 end

        valid();
        birthdaypicker('.layui-order-form .dtpicker_birth');

    })


    // Update by Xu Lei at 2020.12.15 for 添加百万医疗DTC Start
    //查看保障详情
    $('.btn-security').click(function () {

        //console.log(tempcontent);
        if ($("input[name='ProductCode']").val() == '180301' || $("input[name='ProductCode']").val() == '180302' || $("input[name='ProductCode']").val() == '18030101') {
            var tempcontent = $('#iframe_tpl-benefit-detail').html();
            //alert(tempcontent);
            // alert("查看保障详情");
            layer.open({
                className: 'layui-order-iframe  page-baozhang-content'
                , title: [
                    '<a href="javascript:;" class="layui-iframe-close">关闭</a>保障详情',
                    'background-color:#efefef;height:1.75rem;line-height:1.75rem;color:#121791;font-size:.6rem;'
                ]
                , type: 1
                , content: tempcontent
                , anim: 'up'
                , style: 'position:fixed; bottom:0; left:0; width: 100%; height: 100%; padding:10px 0; border:none;'
            });
        } else {
            var tempcontent = $('#iframe_tpl-benefit-detail').html();
            // alert("查看保障详情");
            layer.open({
                className: 'layui-order-iframe'
                , title: [
                    '<a href="javascript:;" class="layui-iframe-close"></a>保障详情',
                    'background-color:#efefef;height:1.75rem;line-height:1.75rem;color:#121791;font-size:.6rem;'
                ]
                , type: 1
                , content: '<a href="javascript:;" class="layui-iframe-close"></a>' + tempcontent
                , anim: 'up'
                , style: 'position:fixed; bottom:0; left:0; width: 100%; height: 390px; padding:10px 0; border:none;'
            });
        }
    })
    // Update by Xu Lei at 2020.12.15 for 添加百万医疗DTC End

    //返回并重新投保
    $('.btn-back').click(function () {
        var datavalue = $(this).attr("data-value");
        // alert("返回并重新投保");
        layer.open({
            className: 'layui-order-tip order-goback'
            , title: [
                '提示<a href="javascript:;" class="layui-tip-close"></a>',
                'background-color:#f1f9ff;color:#fff;border-radius:0;color:#333;font-size:.6rem;height:1.75rem;line-height:1.75rem;'
            ]
            , anim: 'up'
            // Update by Xu Lei Start on 2019.9.3 提示内容更新
            , content: '<p style="font-size:.6rem;color:#333;text-align:center;padding:1.25rem 0;"><img src="https://mall.aig.com.cn/mimg/order/layer-tip1.png" style="display:block;margin:0 auto 0.6rem;">请确认是否要离开，离开后页面信息将丢失，<br>若想保存信息请先注册登录。</p>'//add by eren 201909018 change the image path
            , btn: ['留在此页', '离开']
            , no: function (index) {
                // window.onbeforeunload = null;
                // Update by Xu Lei End on 2019.9.3 提示内容更新
                //alert(parterCode);
                //window.location.href = 'international-travel.html'
                var parterCode = $("#parterCode").val();
                var ProductCode = $("input[name='ProductCode']").val();
                //IPA
                if (ProductCode == "150034") {
                    window.location.href = '/' + parterCode + 'ipa-ah.html';

                }
                //IPA01 update by lisa，PC wap ipa官网定制，需要跳转获取aem的产品页面
                else if (ProductCode == "15003401") {
                    window.location.href = '/' + parterCode + 'accident_health_ipa.html';

                }
                //GBA
                else if (ProductCode == "150331") {
                    window.location.href = '/' + parterCode + 'gba-ah.html';
                }
                // Add by Xu Lei at 2020.10.27 for 添加百万医疗DTC Start
                else if (ProductCode == "180301") {
                    if (parterCode.toLowerCase() == 'wechat/')
                    {
                        window.location.href = '/' + parterCode + 'ahprice-dtc.html';
                    }
                    else
                    {
                        window.location.href = '/' + parterCode + 'accident_health_dtc.html';
                    }
                }
                // Add by Xu Lei at 2020.10.27 for 添加百万医疗DTC End
                else if (ProductCode == "18030101") {
                    if (parterCode.toLowerCase() == 'wechat/') {
                        window.location.href = '/' + parterCode + 'ahprice-dtcDiscount-price.html';
                    }
                    else {
                        window.location.href = '/' + parterCode + 'ahprice-dtcDiscount.html';
                    }
                }

                //Add by qufeng at 2022.01.13 for 添加新一生康美 Start
                else if (ProductCode == "180302") {
                    if (parterCode.toLowerCase() == 'wechat/') {
                        window.location.href = '/' + parterCode + 'dtc-ah.html';
                    }
                    else {
                        window.location.href = '/' + parterCode + 'ahprice-dtc-ah.html';
                    }
                }
                //Add by qufeng at 2022.01.13 for 添加新一生康美 End
                    //Add by Amy at 2021.06.01 for 添加宝贝无忧 Start
                else if (ProductCode == "020606") {
                        window.location.href = '/' + parterCode + 'ahprice-Baby-safe.html';
                }
                else if (ProductCode == "0206062") {
                    window.location.href = '/' + parterCode + 'ahprice-Babysafe-gift.html';
                }
                    //Add by Amy at 2021.06.01 for 添加宝贝无忧 End
                else if (ProductCode == "0206061") {//Add by amy 新冠疫苗VPA
                    window.location.href = '/' + parterCode + 'ahprice-VPA.html';

                //Add by Qufeng.Liu at 2021.09.03 for 添加银发守护者 Start
                } else if (ProductCode == "0206063") {
                    window.location.href = '/' + parterCode + 'ahprice-epa.html';
                }
                //Add by Qufeng.Liu at 2021.09.03 for 添加银发守护者 End
                // 主页
                else {
                    window.location.href = '/' + parterCode;
                }


            }
        });
    })

    //删除被保险人
    $(document).on('click', '.btn-add-insured-del', function () {
        //只有一个被保人不让删除
        if ($('#step-insured .step-info-box .step-info').length <= 1) {
            layer.open({
                className: 'layui-order-msg'
                , content: '请至少保留一个被保人'
                , skin: 'msg'
                , time: 1.5
            });
            return false;
        }

        var $this = $(this);
        var name = $this.attr('data-name');
        var currentIndex = $this.attr('currentIndex');
        layer.open({
            className: 'layui-order-tip'
            , title: [
                '提示<a href="javascript:;" class="layui-tip-close"></a>',
                'background-color:#f1f9ff;color:#fff;border-radius:0;color:#333;font-size:.6rem;height:1.75rem;line-height:1.75rem;'
            ]
            , anim: 'up'
            , content: '<p style="font-size:.6rem;color:#333;text-align:center;padding:1.25rem 0;"><img src="https://mall.aig.com.cn/mimg/order/layer-tip2.png" style="display:block;margin:0 auto 0.6rem;">你确认要删除 ' + name + '？</p>'//update by eren 20190918 change the image path
            , btn: ['确认', '取消']
            , yes: function (index) {
                layer.closeAll();
                $this.closest('.step-info').remove();
                //至少有一个被保人 需要重新去询价.
                if ($('#step-insured .step-info-box .step-info').is(":visible")) {
                    // 被保险人下标再整理
                    RefreshInputAttribute("itemAdd");


                    $("#IsQuotoPrice").val("1");
                    QuotoPriceMethod(false);

                    //删除被保人需要更新全局变量 
                    aig_orderStorage.insured.splice(currentIndex, 1)
                }

            }
        });
    })



    //关闭浮窗弹出层
    $(document).on('click', '.layui-order-form .layui-order-close, .layui-order-iframe .layui-iframe-close, .layui-order-tip .layui-tip-close', function () {
        layer.closeAll();

        $('body').removeClass('layer-board');

        //编辑状态关闭
        $("#editstatus").val("false");

    })

    // updateEndDate by lisa 20240204 注意事项全部默认展开，不弹窗显示， 去掉之前的弹窗
    //投保须知
    //$('.rules-box .rules-tit').click(function () {
    //    // Update 2021.01.05 for 更新一生康美DTC Start
    //    if($('body').hasClass('page-order-bwyl')){
    //        var i = $(this).parent().index() * 1 + 1;
    //        var tempcontent = $('#layer-tpl-xuzhi' + i).html();
    //        layer.open({
    //           className: 'layer-content-full layui-order-iframe'
    //           , title: [
    //               '<a href="javascript:;" class="layui-iframe-close layui-iframe-close2">确认</a>投保须知',
    //               'background-color:#fff;height:1.75rem;line-height:1.75rem;color:#121791;font-size:.6rem;position:relative;border-bottom:1px solid #f2f2f2;'
    //           ]
    //           , type: 1
    //           , anim: 'up'
    //           , scrollbar: false
    //           , style: 'position:fixed; bottom:0; left:0; width: 100%; height: 100%; padding:10px 0; border:none;'
    //           , content: '<div><div class="v2-order-rules">' + tempcontent + '</div></div>'
    //        });
    //    }else{
    //        $(this).parent().toggleClass('unshow');
    //    }
    //    // Update 2021.01.05 for 更新一生康美DTC End
    //})
    //update by Amy at 2021.06.01 End

    //确认投保须知 html版本的
    $('.agreen>a').click(function () {
        $(this).toggleClass('agreen-checked');
        if ($(this).hasClass('agreen-checked')) {
            //_gsq.push(["T", "GWD-002498", "trackEvent", "投保声明", "继续", location.pathname]);

            // Add Start by Kevin 2018/11/28 Hotfix_UpliftGridSumDissector 更新国双eTravel检测代码
            //当用户勾选投保声明时
            _gsq.push(["track", "c_interact", { c_page_cate: "保单页", c_botton_cate: "保单页信息填写", c_botton_loc: "声明勾选_全部内容", c_button_name: "声明勾选_全部内容",c_botton_url: "-", c_pro_name: $("input[name='productName']").val()}]);
            //alert("投保声明-勾选" + $("#productName").val() + "-" + (($("#PartnerCode").val() == "wechat") ? "WeChat端" : "Mob端"));
            // Add End by Kevin 2018/11/28 Hotfix_UpliftGridSumDissector 更新国双eTravel检测代码

            // Update Start by Kevin 2019/01/21 Hotfix_AddAdobeInspector etravel的购买页面增加ADOBE的监测代码和检测数据PC，WAP，WECHAT端
            UpdateAdobeInspector("9", "投保声明-勾选");
            console.log(digitalData);
            // Update End by Kevin 2019/01/21 Hotfix_AddAdobeInspector etravel的购买页面增加ADOBE的监测代码和检测数据PC，WAP，WECHAT端

            // =====2019.11.1 根据升级保障，切换PDF版本
            var ProductCode = $("input[name='ProductCode']").val();
            var contenthtml;
            //IPA
            if (ProductCode == "150034") {
                // var pdf_version = $("#DelayAdditional").val() == "1" ? 'm' : 's';
                if ($("#DelayAdditional").val() == '1' && $("#ContagionAdditional").val() == '1') {
                    var pdf_version = 'm_ct';
                }
                else if ($("#DelayAdditional").val() == '1' && $("#ContagionAdditional").val() != '1') {
                    var pdf_version = 'm';
                }
                else if ($("#DelayAdditional").val() != '1' && $("#ContagionAdditional").val() == '1') {
                    var pdf_version = 'ct';
                }
                else if ($("#DelayAdditional").val() != '1' && $("#ContagionAdditional").val() != '1') {
                    var pdf_version = 's';
                }
                var contenthtml = $('#pdf-ipa_' + pdf_version).html();
            }
            //IPA01
            else if (ProductCode == "15003401") {
                //var pdf_version = $("#DelayAdditional").val() == "1" ? 'm' : 's';
                if ($("#DelayAdditional").val() == '1' && $("#ContagionAdditional").val() == '1') {
                    var pdf_version = 'm_ct';
                }
                else if ($("#DelayAdditional").val() == '1' && $("#ContagionAdditional").val() != '1') {
                    var pdf_version = 'm';
                }
                else if ($("#DelayAdditional").val() != '1' && $("#ContagionAdditional").val() == '1') {
                    var pdf_version = 'ct';
                }
                else if ($("#DelayAdditional").val() != '1' && $("#ContagionAdditional").val() != '1') {
                    var pdf_version = 's';
                }
                var contenthtml = $('#pdf-ipa_' + pdf_version).html();
            }
            //GBA
            else if (ProductCode == "150331") {
                var contenthtml = $('#pdf-gba').html();
            }
            //Update by Xu Lei at 2020.10.30 for 添加百万医疗DTC Start
            else if (ProductCode == "180301" || ProductCode == "18030101" || ProductCode == "180302") {
                var contenthtml = $('#pdf-bwyl').html()
            }
           //Add by Amy at 2021.06.01 for 添加宝贝无忧 Start
            else if (ProductCode == "020606" || ProductCode == "0206062") {
                var contenthtml = $('#layer-tpl-hetong').html();
            }
            //Add by Amy at 2021.06.01 for 添加宝贝无忧 End
            else if (ProductCode == "0206061") {//新冠疫苗
                var contenthtml = $('#layer-tpl-hetong-VPA').html();
            }
            //Add by Qufeng.Liu at 2021.08.31 for 添加银发守护者 Start
            else if (ProductCode == "0206063") {
                var contenthtml = $('#layer-tpl-hetong-epa').html();
            }
            //Add by Qufeng.Liu at 2021.08.31 for 添加银发守护者 End

            //Update by Xu Lei at 2020.10.30 for 添加百万医疗DTC End
            // update start by jing 2024/03/02 添加【我已阅读并同意】按钮样式切换和滚动条滚动到底部才可以点击
            layer.open({
                className: 'layui-order-iframe layui-order-iframe2 layer-order-pdfbox'
                , title: [
                    '<a href="javascript:;" class="layui-iframe-close2 layui-iframe-close3">我已阅读并同意</a><span class="layui-iframe-close-tip">阅读到页面底部后可点击</span>请滑动到底部，阅读免除保险公司责任条款全文',
                    'background-color:#efefef;height:1.75rem;line-height:1.75rem;color:#00a4e4;font-size:.5rem;'
                ]
                , type: 1
                , shadeClose: false//开启遮罩关闭
                , success: function (layero, index) {
                    $('.layui-order-iframe .layui-iframe-close3').click(function () {
                        if ($(this).hasClass('layui-iframe-close-enable')) {
                            layer.closeAll();
                            $('body').removeClass('layer-board');
                            //编辑状态关闭
                            $("#editstatus").val("false");
                        }
                    });
                    var $element = $('.layui-order-iframe .layui-m-layercont')
                    $element.scroll(function () {
                        //console.log('滚动条滚动了！', $element.scrollTop(), $element.innerHeight(), $element[0].scrollHeight);
                        // 检查元素是否滚动到底部  
                        if ($element.scrollTop() + $element.innerHeight() + 12 >= $element[0].scrollHeight) {
                            // layer.close()   
                            // 滚动到底部的处理逻辑  
                            //console.log('滚动条已经滚动到底部了！');
                            $('.layui-iframe-close-tip').css('display', 'none');

                            $('.layui-order-iframe .layui-iframe-close3').addClass('layui-iframe-close-enable')
                        }
                    });
                }
                , content: $('#pdf-mianzes').html()//pdf-contract
                 // update end by jing 2024/03/02 添加【我已阅读并同意】按钮样式切换和滚动条滚动到底部才可以点击
                , anim: 'up'
                , style: 'position:fixed; bottom:0; left:0; width: 100%; height: 390px; padding:10px 0; border:none;'
                // Add Start by Kevin 2018/11/28 Hotfix_UpliftGridSumDissector 更新国双eTravel检测代码
                , end: function () {
                    //当用户确认保险合同时
                   _gsq.push(["track", "c_interact", { c_page_cate: "保单页", c_botton_cate: "保单页信息填写",c_botton_loc: "责任免除条款-确定", c_button_name: "责任免除条款-确定",c_botton_url: "-", c_pro_name: $("input[name='productName']").val() }]);
                    //alert("保险合同-确认" + $("#productName").val() + "-" + (($("#PartnerCode").val() == "wechat") ? "WeChat端" : "Mob端"));

                    // Update Start by Kevin 2019/01/21 Hotfix_AddAdobeInspector etravel的购买页面增加ADOBE的监测代码和检测数据PC，WAP，WECHAT端
                    UpdateAdobeInspector("9", "保险合同-确认");
                    console.log(digitalData);
                    // Update End by Kevin 2019/01/21 Hotfix_AddAdobeInspector etravel的购买页面增加ADOBE的监测代码和检测数据PC，WAP，WECHAT端
                }
                // Add End by Kevin 2018/11/28 Hotfix_UpliftGridSumDissector 更新国双eTravel检测代码
            });
            // =====2019.11.1 根据升级保障，切换PDF版本 end
        }


        //调用异步保存数据
        formSubmitByAjax(true);
    })

    // =====2024.07.11 保险合同弹窗
    $('#showpdf').click(function () {

        // var ProductCode = $("input[name='ProductCode']").val();
        var ProductCode = "xingyunguo";
        var contenthtml;
        //IPA
        if (ProductCode == "150034") {
            // var pdf_version = $("#DelayAdditional").val() == "1" ? 'm' : 's';
            //change by Eric 2020/7/27
            if ($("#DelayAdditional").val() == '1' && $("#ContagionAdditional").val() == '1') {
                var pdf_version = 'm_ct';
            }
            else if ($("#DelayAdditional").val() == '1' && $("#ContagionAdditional").val() != '1') {
                var pdf_version = 'm';
            }
            else if ($("#DelayAdditional").val() != '1' && $("#ContagionAdditional").val() == '1') {
                var pdf_version = 'ct';
            }
            else if ($("#DelayAdditional").val() != '1' && $("#ContagionAdditional").val() != '1') {
                var pdf_version = 's';
            }
            var contenthtml = $('#pdf-ipa_' + pdf_version).html();
        }else if (ProductCode == "xingyunguo") {
            var contenthtml = $('#pdf-xingyunguo').html();
        }
        //IPA01
        else if (ProductCode == "15003401") {
            //var pdf_version = $("#DelayAdditional").val() == "1" ? 'm' : 's';
            //change by Eric 2020/7/27
            if ($("#DelayAdditional").val() == '1' && $("#ContagionAdditional").val() == '1') {
                var pdf_version = 'm_ct';
            }
            else if ($("#DelayAdditional").val() == '1' && $("#ContagionAdditional").val() != '1') {
                var pdf_version = 'm';
            }
            else if ($("#DelayAdditional").val() != '1' && $("#ContagionAdditional").val() == '1') {
                var pdf_version = 'ct';
            }
            else if ($("#DelayAdditional").val() != '1' && $("#ContagionAdditional").val() != '1') {
                var pdf_version = 's';
            }
            var contenthtml = $('#pdf-ipa_' + pdf_version).html();
        }
        //GBA
        else if (ProductCode == "150331") {
            var contenthtml = $('#pdf-gba').html();
        }
        //Update by Xu Lei at 2020.10.30 for 添加百万医疗DTC Start
        else if (ProductCode == "180301" || ProductCode == "18030101" || ProductCode == "180302") {
            var contenthtml = $('#pdf-bwyl').html()
        }
        //Update by Xu Lei at 2020.10.30 for 添加百万医疗DTC End
        //Add by Amy at 2021.06.01 for 添加宝贝无忧 Start
        else if (ProductCode == "020606"||ProductCode == "0206062") {
            var contenthtml = $('#layer-tpl-hetong').html();
        }
        //Add by Amy at 2021.06.01 for 添加宝贝无忧 End
        else if (ProductCode == "0206061") {//新冠疫苗
            var contenthtml = $('#layer-tpl-hetong-VPA').html();
        }
        //Add by Qufeng.Liu at 2021.08.31 for 添加银发守护者 Start
        else if (ProductCode == "0206063") {
            var contenthtml = $('#layer-tpl-hetong-epa').html();
        }
            //Add by Qufeng.Liu at 2021.08.31 for 添加银发守护者 End
        layer.open({
            className: 'layui-order-iframe layui-order-iframe2 layer-order-pdfbox'
            , title: [
                '<a href="javascript:;" class="layui-iframe-close layui-iframe-close2">确认</a>保险条款',
                'background-color:#efefef;height:1.75rem;line-height:1.75rem;color:#121791;font-size:.6rem;'
            ]
            , type: 1
            , content: '<a href="javascript:;" class="layui-iframe-close layui-iframe-close2">确认</a>' + contenthtml
            , anim: 'up'
            , style: 'position:fixed; bottom:0; left:0; width: 100%; height: 390px; padding:10px 0; border:none;'
            , end: function () {
            }
        });

    })
    // =====2019.11.20 保险合同弹窗 end
    //免责条款
    $(document).on('click', '.btn-mianzes', function () {
        var tempcontent = $('#pdf-mianzes').html();
        layer.open({
            className: 'layui-order-iframe layui-order-iframe2 layer-order-pdfbox'
            , title: [
                '<a href="javascript:;" class="layui-iframe-close layui-iframe-close2">确认</a>免除保险公司责任条款',
                'background-color:#efefef;height:1.75rem;line-height:1.75rem;color:#121791;font-size:.6rem;'
            ]
            , type: 1
            , content: tempcontent
            , anim: 'up'
            , style: 'position:fixed; bottom:0; left:0; width: 100%; height: 390px; padding:10px 0; border:none;'
            , end: function () {
            }
        });
    })


    //点击问号提示文字
    $('.tip-box').click(function () {
        var $this = $(this);
        layer.open({
            className: 'layui-order-tip'
            , title: [
                '提示<a href="javascript:;" class="layui-tip-close"></a>',
                'background-color:#f1f9ff;color:#fff;border-radius:0;color:#333;font-size:.6rem;height:1.75rem;line-height:1.75rem;'
            ]
            , anim: 'up'
            , content: '<div class="tipso">' + $this.find('.tipso').html() + '</div>'
        });
    })

    /*
     *  输入错误提示时，再次输入点击去掉错误
     */
    $(document).on('focus', 'input.Validform_error', function () {
        //$(this).removeClass('Validform_error').val('');
        //修复二次验证失败
        $(this).addClass("Validform_error2").val('');
        if ($(this).attr('rel') == 'age')
            $(this).click()
    })
    $(document).on('blur', 'input.Validform_error', function () {
        var err = $(this).attr('nullmsg');
        if ($(this).val() !== '')
            err = $(this).attr('errormsg');
        //add by lisa 具体出生日期错误提示被覆盖的问题
        if ($(this).attr('rel') == 'idno' && $(this).attr('tipmsg') !== '') {
            err = $(this).attr('tipmsg');
        }
        $(this).removeClass('Validform_error2').val(err);
    })
    //验证姓名空格问题
    //$(document).on('blur', '.item-control input', function () {
    //    var v = $(this).val().replace(/(^\s*)|(\s*$)/g, '');
    //    $(this).val(v);
    //});


    // Update Start by Kevin 2019/01/07 ETV.CHI.G1.001.003.78 Echo微信提出WAP端投被保人输入时，email被遮挡
    ///**在安卓手机上投保人被保人输入框被输入键盘遮挡问题*/
    ////$(document).on('focus', '.layui-order-form .v2-order-step input', function () {
    ////    var target = this;
    ////    $(this).closest('.v2-order-step').addClass('mod-scroll-y');
    ////    this.scrollIntoViewIfNeeded();
    ////});
    ///**在安卓手机上投保人被保人输入框被输入键盘遮挡问题*/
    ////解决下拉框错位
    //if (/(Android)/i.test(navigator.userAgent)) {//判断Android

    //    $(document).on('focus', '.layui-order-form .v2-order-step input', function () {
    //        var target = this;
    //        $(this).closest('.v2-order-step').addClass('mod-scroll-y');
    //        this.scrollIntoViewIfNeeded();
    //    })
    //}

    $(document).on('focus', '.layui-order-form .v2-order-step input', function () {
        if ($(this).attr('rel') == 'age')
            return false;
        var target = this;
        $(this).closest('.v2-order-step').addClass('mod-scroll-y');
        this.scrollIntoViewIfNeeded();
    })
    //判断Android
    if (/(Android)/i.test(navigator.userAgent)) {
        var winHeight = $(window).height();
        $(window).resize(function () {
            var thisHeight = $(this).height();
            if (winHeight - thisHeight > 50) {
                $('.layui-order-form .v2-order-step').addClass('mod-scroll-y');

            } else {
                $('.layui-order-form .v2-order-step').removeClass('mod-scroll-y');

            }
        });
    }
    //判断iOS
    if (/(iPhone|iPad|iPod|iOS)/i.test(navigator.userAgent)) {
        $(document).on("focus", "input, textarea", function (e) {
            $('.layui-order-form .v2-order-step').addClass('mod-scroll-y');
        })
        $(document).on("blur", "input, textarea", function (e) {
            $('.layui-order-form .v2-order-step').removeClass('mod-scroll-y');
        })
    }
    // Update End by Kevin 2019/01/07 ETV.CHI.G1.001.003.78 Echo微信提出WAP端投被保人输入时，email被遮挡


    //验证表单数据
    $('#v2-order-form').Validform({
        btnSubmit: '.buy',
        showAllError: true,
        tiptype: function (msg, o, cssctl) {
            if (o.type != 2) {
                o.obj.val(msg);
                //o.obj.val(msg).removeClass('Validform_error2');
            }
        },
        datatype: {
            'm': /^1[0-9]{10}$/,
            'name': function (gets,obj) {
                var reg = /^([A-Za-z\s\‘\/\,]{1,20}|[\u4E00-\u9FA5\s\‘\/\,]{2,4})+$/;
                if (reg.test(gets) && gets.indexOf("  ") < 0 && gets.indexOf('被保险人') < 0 && gets.indexOf('投保人') < 0) {
                    obj.removeClass('Validform_error');
                    return true;
                }
                obj.addClass('Validform_error');
                return false;
            },
            'space': function (gets, obj) {
                if (!!gets) {
                    if (obj != undefined && obj.length > 0) {
                        if (obj[0].id == 'ApplicantIdType')
                            _gsq.push(["track", "c_interact", { c_page_cate: "保单页", c_botton_cate: "保单页信息填写",c_botton_loc: "证件类型", c_button_name: "投保人",c_botton_url: "-", c_pro_name: $("input[name='productName']").val()}]);
                        else if (obj[0].id == 'InsuredIdType')
                            _gsq.push(["track", "c_interact", { c_page_cate: "保单页", c_botton_cate: "保单页信息填写",c_botton_loc: "证件类型", c_button_name: "被保险人",c_botton_url: "-", c_pro_name: $("input[name='productName']").val()}]);
                    }
                }
                if (gets.trim() == "" || gets == "请填写详细地址" || gets == "请选择居住地址" || gets == "请选择所在地" || gets.indexOf("格式不正确") != -1 || gets == '请选择证件类型' || gets == '请正确填写地址' || gets == '请选择' || gets == '请填写') {
                    arguments[1].addClass('Validform_error');
                    return false;
                }
                return true;
            }
        },
        beforeCheck: function () {
            $('input.Validform_error').val('')
        },
        beforeSubmit: function () {

            if (!orderconfirm) {
                return false;
            }
        }
    })

    //确认购买按钮
    $('.buy').click(function () {
       
        // Add Start by Kevin 2018/11/28 Hotfix_UpliftGridSumDissector 更新国双eTravel检测代码
        //当用户点击确认并继续时
         _gsq.push(["track", "c_interact", { c_page_cate: "保单页", c_botton_cate: "保单页信息填写",c_botton_loc: "确认并继续", c_button_name: "确认并继续",c_botton_url: "-", c_pro_name: $("input[name='productName']").val() }]);
        //alert("确认并继续" + $("#productName").val() + "-" + (($("#PartnerCode").val() == "wechat") ? "WeChat端" : "Mob端"));
        // Add End by Kevin 2018/11/28 Hotfix_UpliftGridSumDissector 更新国双eTravel检测代码

        // Update Start by Kevin 2019/01/21 Hotfix_AddAdobeInspector etravel的购买页面增加ADOBE的监测代码和检测数据PC，WAP，WECHAT端
        UpdateAdobeInspector("1", "确认并继续");
        console.log(digitalData);
        // Update End by Kevin 2019/01/21 Hotfix_AddAdobeInspector etravel的购买页面增加ADOBE的监测代码和检测数据PC，WAP，WECHAT端

        // alert("下单");
        console.log("下单");
        //判断投保人信息是否录入
        if (!$('#step-applicant .step-info-box .step-info').is(":visible")) {
            $('#step-applicant .btn-add-applicant').next('p').show();
            $body.animate({
                scrollTop: 220
            }, 1000);
            return false;
        }
        //判断被保险人信息是否录入
        if (!$('#step-insured .step-info-box .step-info').is(":visible")) {
            $('#step-insured .btn-add-insured').next('p').show();
            $body.animate({
                scrollTop: 770
            }, 1000);
            return false;
        }
        //判断快递信息是否录入
        if ($('.step-form-express .Validform_error').length > 0) {
            layer.open({
                className: 'layui-order-msg'
                , content: '请完善快递信息'
                , skin: 'msg'
                , time: 1.5
            });
            return false;
        }

        /**
        * 20220401
        * 勾选投保人/被保险人个人信息申明
        */
        if (!check_statement())
            return false;
        // 20220401 勾选投保人/被保险人个人信息申明 End

        //判断阅读条款是否已阅读
        if (!$('.agreen-check').hasClass('agreen-checked')) {
            layer.open({
                className: 'layui-order-msg'
                , content: '请完整阅读并确认投保须知'
                , skin: 'msg'
                , time: 2
            });

            $body.animate({
                scrollTop: $('.v2-order-rules').offset().top - 100
            }, 1000);
            return false;
        }

        //判断后台校验数据是否通过
        if (!validatePage(false)) {
            return false;
        }

        //询价
        if (!QuotoPriceMethod(false, true)) {
            return false;
        }
        //Masa验证码
        if ($("#OrderCount").val() == "True") {
            var flag = OrderGoToComfirm();
            if (flag == "false") {
                return false;
            }
        }
        //判断是否确认过订单信息
        if (!orderconfirm) {
            var lock = false;//用来锁定确认按钮，防止重复提交（默认未锁定）
            var layer_confirm = layer.open({
                className: 'layui-order-tip'
                , title: [
                    '提示',
                    'background-color:#f1f9ff;color:#fff;border-radius:0;color:#333;font-size:.6rem;height:1.75rem;line-height:1.75rem;'
                ]
                , anim: 'up'
                , content: '<p style="font-size:.6rem;color:#333;text-align:center;padding:1.25rem 0;"><img src="https://mall.aig.com.cn/mimg/order/layer-tip3.png" style="display:block;margin:0 auto 0.6rem;">请确认投保信息填写无误\n</p>'//add by eren 20190918 change the image path
                , btn: ['确认并付款', '检查一下']
                , yes: function (index) {
                    if (!lock) {
                        lock = true;//锁定
                        // Add Start by Kevin 2018/11/28 Hotfix_UpliftGridSumDissector 更新国双eTravel检测代码
                        //当用户点击确认并付款时
                         _gsq.push(["track", "c_interact", { c_page_cate: "保单页", c_botton_cate: "保单页信息填写",c_botton_loc: "确认并付款", c_button_name: "确认并付款",c_botton_url: "-", c_pro_name: $("input[name='productName']").val() }]);
                        //alert("确认并付款" + $("#productName").val() + "-" + (($("#PartnerCode").val() == "wechat") ? "WeChat端" : "Mob端"));
                        // Add End by Kevin 2018/11/28 Hotfix_UpliftGridSumDissector 更新国双eTravel检测代码

                        // Update Start by Kevin 2019/01/21 Hotfix_AddAdobeInspector etravel的购买页面增加ADOBE的监测代码和检测数据PC，WAP，WECHAT端
                        UpdateAdobeInspector("2", "确认并付款");
                        console.log(digitalData);
                        // Update End by Kevin 2019/01/21 Hotfix_AddAdobeInspector etravel的购买页面增加ADOBE的监测代码和检测数据PC，WAP，WECHAT端


                        console.log("同步保存订单");
                        // alert("保存数据");
                        // 同步保存 ORDER 表， 而非 ORDER_TEMP 表
                        $("#IsTemporary").attr("value", "0");
                        var resultFlag = formSubmitByAjax(false);
                        // alert("formSubmitByAjax:" + resultFlag);
                        if (!resultFlag) {
                            $(".promptInquiry").css("color", "red");
                            $(".promptInquiry").html("保存订单失败");
                            console.log("同步保存订单失败");
                            layer.close(layer_confirm);
                            return false;
                        }
                        // window.onbeforeunload = null;
                        //alert("表单提交");
                        orderconfirm = true;
                        //form的action再设定,再提交。
                        //Update by Qufeng at 2021/10/22 kidspa出单 Start
                        if ($("#ProductCode").val() == "0206062") {
                            $.ajax({
                                cache: false,
                                type: "POST",
                                url: "/common/Payment/KidsPA_NotifyResult",
                                data: {
                                    transactionNo: $("#TransactionId").val(),
                                },
                                async: false,
                                error: function (request) {

                                },
                                success: function (data) {
                                    if (data == "success") {
                                        //$("#v2-order-form").attr("action", "@Url.Action("Payment", "Purchase", new { isMobile = "true" })" + "?productCode=" + $("#ProductCode").val() + "&transactionId=" + $("#TransactionId").val() + "&TranSign=" + $("#TranSign").val());
                                        setSubmitForm();
                                        $("#v2-order-form")[0].submit();//update by eren 20190926 jquery的submit无法提交，先改为js的submit
                                    } else {
                                        var url = document.location.origin + "/ad/kidspa/result.html";
                                        window.location = url;
                                    }

                                }
                            });
                        } else {
                            setSubmitForm();
                            //$("#v2-order-form").submit();
                            $("#v2-order-form")[0].submit();//update by eren 20190926 jquery的submit无法提交，先改为js的submit
                        }

                        //Update by Qufeng at 2021/10/22 kidspa出单 End



                        //这是最后一步确认
                        //alert("确认并继续,检查一下");


                        //aig_orderStorage.express = {
                        //    'name': $('#ExpressReceiverName').val(),
                        //    'mobile': $('#ExpressReceiverNumber').val(),
                        //    'province': $('#ExpressReceiverProvince').val(),
                        //    'address': $('#ExpressReceiverAddress').val()
                        //};
                        //window.location.href = 'pay.html';
                        //$.ajax({
                        //    url: 'https://www.aig.com.cn/',
                        //    data: aig_orderStorage,
                        //    type: 'POST',
                        //    dataType: 'json',
                        //    success: function (res) {
                        //        console.log(res);
                        //    },
                        //    error: function (msg) {
                        //        console.log(msg);
                        //    }
                        //})
                    }
                }
                , no: function () {
                    $body.animate({
                        scrollTop: $('#step-applicant').offset().top - 5
                    }, 1000);
                }
            });
            return false;
        }


    })


    // Add Baidu oCPC Kevin 2019/02/27 Add Begin
    window._agl && window._agl.push(['track', ['success', { t: 3 }]]);
    // Add Baidu oCPC  Kevin 2019/02/27 Add End



})


//验证订单的状态  日期格式（年龄确认）
function valid() {

    ordervalid = $('.layui-m-layer .layui-order-form').Validform({
        btnSubmit: '.layui-m-layerbtn',
        showAllError: true,
        tiptype: function (msg, o, cssctl) {

            if (o.type != 2) {

                if (msg.indexOf('请选择') != -1 || msg.indexOf('请填写') != -1) {
                    o.obj.addClass('Validform_error');
                }else{
                    //修复二次验证失败
                    o.obj.val(msg).removeClass("Validform_error2");
                }
            }
        },
        datatype: {
            // UP：2020.02.22
            'salary': /^(?!0)(?:[0-9]{1,6})$/,
            // Update Start by Kevin 2019/09/27 ETV.CHI.G1.001.003.89 手机号check的规则修改
            //'m': /^1\d{10}$/,
            'm': function (gets, obj) {
                if (!!gets) {
                    if (obj != undefined && obj.length > 0) {
                        if (obj[0].id == 'ApplicantMobile')
                             _gsq.push(["track", "c_interact", { c_page_cate: "保单页", c_botton_cate: "保单页信息填写",c_botton_loc: "手机号码", c_button_name: "投保人",c_botton_url: "-", c_pro_name: $("input[name='productName']").val()}]);
                        else
                             _gsq.push(["track", "c_interact", { c_page_cate: "保单页", c_botton_cate: "保单页信息填写",c_botton_loc: "手机号码", c_button_name: "被保险人",c_botton_url: "-", c_pro_name: $("input[name='productName']").val()}]);
                    }
                }
                var reg = /^1[0-9]{10}$/;
                return reg.test(gets);
            },
            // Update End by Kevin 2019/09/27 ETV.CHI.G1.001.003.89 手机号check的规则修改

            'inputCheck': function (gets, obj) {
                if (!!gets) {
                    if (obj != undefined && obj.length > 0) {
                        if (obj[0].id == 'ApplicantIdType')
                            _gsq.push(["track", "c_interact", { c_page_cate: "保单页", c_botton_cate: "保单页信息填写",c_botton_loc: "证件类型", c_button_name: "投保人",c_botton_url: "-", c_pro_name: $("input[name='productName']").val()}]);
                        else
                            _gsq.push(["track", "c_interact", { c_page_cate: "保单页", c_botton_cate: "保单页信息填写",c_botton_loc: "证件类型", c_button_name: "被保险人",c_botton_url: "-", c_pro_name: $("input[name='productName']").val()}]);
                    }
                }
                if (gets.indexOf('请选择证件类型') >= 0 || gets == "") {
                    return false;
                }
                return true;
            },
            //update by Eren js升级的代码 20190419 start
            //'no': /^[A-Za-z0-9]+$/,
            'no': function (gets, obj) {
                if (!!gets) {
                    if (obj != undefined && obj.length > 0) {
                        if (obj[0].id == 'ApplicantIdNumber')
                            _gsq.push(["track", "c_interact", { c_page_cate: "保单页", c_botton_cate: "保单页信息填写",c_botton_loc: "证件号码", c_button_name: "投保人",c_botton_url: "-", c_pro_name: $("input[name='productName']").val()}]);
                        else
                            _gsq.push(["track", "c_interact", { c_page_cate: "保单页", c_botton_cate: "保单页信息填写",c_botton_loc: "证件号码", c_button_name: "被保险人",c_botton_url: "-", c_pro_name: $("input[name='productName']").val()}]);
                    }
                }
                var reg = /^[A-Za-z0-9]+$/;
                return reg.test(gets);
            },
            //update by Eren js升级的代码 20190419 end
            'name': function (gets, obj) {
                if (!!gets) {
                    if (obj != undefined && obj.length > 0) {
                        if (obj[0].id == 'ApplicantName')
                             _gsq.push(["track", "c_interact", { c_page_cate: "保单页", c_botton_cate: "保单页信息填写",c_botton_loc: "姓名", c_button_name: "投保人",c_botton_url: "-", c_pro_name: $("input[name='productName']").val()}]);
                        else
                             _gsq.push(["track", "c_interact", { c_page_cate: "保单页", c_botton_cate: "保单页信息填写",c_botton_loc: "姓名", c_button_name: "被保险人",c_botton_url: "-", c_pro_name: $("input[name='productName']").val()}]);
                    }
                }
                var reg = /^([A-Za-z\s\‘\/\,]{1,20}|[\u4E00-\u9FA5\s\‘\/\,]{2,4})+$/;
                if (reg.test(gets) && gets.indexOf("  ") < 0 && gets.indexOf('被保险人') < 0 && gets.indexOf('投保人') < 0) {
                    obj.removeClass('Validform_error');
                    return true;
                }
                obj.addClass('Validform_error');
                return false;
            },
            'e': function (gets, obj) {
                if (!!gets) {
                    if (obj != undefined && obj.length > 0) {
                        if (obj[0].id == 'ApplicantEmail')
                            _gsq.push(["track", "c_interact", { c_page_cate: "保单页", c_botton_cate: "保单页信息填写",c_botton_loc: "电子邮箱", c_button_name: "投保人",c_botton_url: "-", c_pro_name: $("input[name='productName']").val()}]);
                        else
                            _gsq.push(["track", "c_interact", { c_page_cate: "保单页", c_botton_cate: "保单页信息填写",c_botton_loc: "电子邮箱", c_button_name: "被保险人",c_botton_url: "-", c_pro_name: $("input[name='productName']").val()}]);
                    }
                }
                var reg = /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/;

                return reg.test(gets);
            },
            'nationality': function (gets, obj) {
                if (!!gets) {
                    if (obj != undefined && obj.length > 0) {
                        if (obj[0].id == 'ApplicantNationality')
                            _gsq.push(["track", "c_interact", { c_page_cate: "保单页", c_botton_cate: "保单页信息填写",c_botton_loc: "国籍", c_button_name: "投保人",c_botton_url: "-", c_pro_name: $("input[name='productName']").val() }]);
                        else
                            _gsq.push(["track", "c_interact", { c_page_cate: "保单页", c_botton_cate: "保单页信息填写",c_botton_loc: "国籍", c_button_name: "被保险人",c_botton_url: "-", c_pro_name: $("input[name='productName']").val() }]);
                    }
                }
                var reg = /^[\S]*（?[\S]*）?[\S]*$/;//update by eren 20190924 修改国籍验证规则
                if (gets != '请选择' && reg.test(gets) && gets != '') {
                    return true;
                }
                return false;
            },
            'livecity': function (gets, obj) {
                if (!!gets) {
                    if (obj != undefined && obj.length > 0) {
                        if (obj[0].id == 'ApplicantLiveCity')
                            _gsq.push(["track", "c_interact", { c_page_cate: "保单页", c_botton_cate: "保单页信息填写", c_botton_loc: "所在地", c_button_name: "投保人", c_botton_url: "-", c_pro_name: $("input[name='productName']").val() }]);
                        else 
                            _gsq.push(["track", "c_interact", { c_page_cate: "保单页", c_botton_cate: "保单页信息填写", c_botton_loc: "所在地", c_button_name: "被保险人", c_botton_url: "-", c_pro_name: $("input[name='productName']").val() }]);
                    }
                }

            },
            'liveaddress': function (gets, obj) {
                if (!!gets) {
                    if (obj != undefined && obj.length > 0) {
                        if (obj[0].id == 'ApplicantLiveAddress')
                            _gsq.push(["track", "c_interact", { c_page_cate: "保单页", c_botton_cate: "保单页信息填写", c_botton_loc: "详细地址", c_button_name: "投保人", c_botton_url: "-", c_pro_name: $("input[name='productName']").val() }]);
                        else
                            _gsq.push(["track", "c_interact", { c_page_cate: "保单页", c_botton_cate: "保单页信息填写", c_botton_loc: "详细地址", c_button_name: "被保险人", c_botton_url: "-", c_pro_name: $("input[name='productName']").val() }]);
                    }
                }

            },
            'd': /^((((19|20)\d{2})-(0?[13-9]|1[012])-(0?[1-9]|[12]\d|30))|(((19|20)\d{2})-(0?[13578]|1[02])-31)|(((19|20)\d{2})-0?2-(0?[1-9]|1\d|2[0-8]))|((((19|20)([13579][26]|[2468][048]|0[48]))|(2000))-0?2-29))|(9999-12-31)$/,
            'idcard': function (gets, obj, curform, datatype) {
                if (!!gets) {
                    if (obj != undefined && obj.length > 0) {
                        if (obj[0].id == 'ApplicantIdCard' || obj[0].id == 'ApplicantIdNumber')
                            _gsq.push(["track", "c_interact", { c_page_cate: "保单页", c_botton_cate: "保单页信息填写",c_botton_loc: "身份证件号码", c_button_name: "投保人",c_botton_url: "-", c_pro_name: $("input[name='productName']").val() }]);
                        else
                            _gsq.push(["track", "c_interact", { c_page_cate: "保单页", c_botton_cate: "保单页信息填写",c_botton_loc: "身份证件号码", c_button_name: "被保险人",c_botton_url: "-", c_pro_name: $("input[name='productName']").val() }]);
                    }
                }
                var reg = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
                if (reg.test(gets) === false) {
                    return false;
                }

                var Wi = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2, 1];
                var ValideCode = [1, 0, 10, 9, 8, 7, 6, 5, 4, 3, 2];
                var date_birth = new Date();
                obj.attr('tipmsg', '');
                //校验空格
                if (gets.indexOf(" ") > -1) {
                    return false;
                }
                if (gets.length == 15) {
                    var birthdate = gets.substring(6, 8);
                    if (birthdate > 20) {
                        birthdate = "19" + birthdate;
                    }
                    else {
                        birthdate = "20" + birthdate;
                    }
                    if (birthdate > date_birth.getFullYear() || birthdate < 1900) {
                        obj.attr('tipmsg', '请输入身份证有效年份');
                        return "请输入身份证有效年份";
                    }
                    if (!checkProvinceOfIPcard(gets)) {
                        obj.attr('errormsg', '请输入身份证有效省份代码');
                        return "请输入身份证有效省份代码";
                    }
                    //15位身份证校验年月日格式
                    return isValidityBrithBy15IdCard(gets);
                } else if (gets.length == 18) {
                    var a_idCard = gets.split("");
                    var birthdate = gets.substring(6, 10);
                    if (birthdate > date_birth.getFullYear() || birthdate < 1900) {
                        obj.attr('tipmsg', '请输入身份证有效年份');
                        return "请输入身份证有效年份";
                    }
                    // layer.open({
                    //     className: 'layui-order-msg'
                    //     , content: '被保险人年龄须为20-45周岁'
                    //     , skin: 'msg'
                    //     , time: 2
                    // });
                    if (!checkProvinceOfIPcard(gets)) {
                        obj.attr('tipmsg', '请输入身份证有效省份代码');
                        return "请输入身份证有效省份代码";
                    }
                    //18位省份证校验年月日格式 &校验最后一位
                    if (isValidityBrithBy18IdCard(gets) && isTrueValidateCodeBy18IdCard(a_idCard)) {
                        return true;
                    }
                    return false;
                }
                return false;
                //校验身份证末位数字
                function isTrueValidateCodeBy18IdCard(a_idCard) {
                    var sum = 0;
                    if (a_idCard[17].toLowerCase() == 'x') {
                        a_idCard[17] = 10;
                    }
                    for (var i = 0; i < 17; i++) {
                        sum += Wi[i] * a_idCard[i];
                    }
                    valCodePosition = sum % 11;

                    
                    if (a_idCard[17] == ValideCode[valCodePosition]) {
                        return true;
                    }
                    return false;
                }
                //省份校验
                function checkProvinceOfIPcard(card) {
                    var vcity = {
                        11: "北京", 12: "天津", 13: "河北", 14: "山西", 15: "内蒙古",
                        21: "辽宁", 22: "吉林", 23: "黑龙江", 31: "上海", 32: "江苏",
                        33: "浙江", 34: "安徽", 35: "福建", 36: "江西", 37: "山东", 41: "河南",
                        42: "湖北", 43: "湖南", 44: "广东", 45: "广西", 46: "海南", 50: "重庆",
                        51: "四川", 52: "贵州", 53: "云南", 54: "西藏", 61: "陕西", 62: "甘肃",
                        63: "青海", 64: "宁夏", 65: "新疆", 71: "台湾", 81: "香港", 82: "澳门"
                    };
                    var province = card.substr(0, 2);
                    if (vcity[province] == undefined) {
                        return false;
                    }
                    return true;
                }
                function isValidityBrithBy18IdCard(idCard18) {
                    var year = idCard18.substring(6, 10);
                    var month = idCard18.substring(10, 12);
                    var day = idCard18.substring(12, 14);
                    var temp_date = new Date(year, parseFloat(month) - 1, parseFloat(day));
                    if (temp_date.getFullYear() != parseFloat(year) || temp_date.getMonth() != parseFloat(month) - 1 || temp_date.getDate() != parseFloat(day)) {
                        return false;
                    }
                    return true;
                }
                function isValidityBrithBy15IdCard(idCard15) {
                    var year = idCard15.substring(6, 8);
                    var month = idCard15.substring(8, 10);
                    var day = idCard15.substring(10, 12);
                    var temp_date = new Date(year, parseFloat(month) - 1, parseFloat(day));
                    if (temp_date.getYear() != parseFloat(year) || temp_date.getMonth() != parseFloat(month) - 1 || temp_date.getDate() != parseFloat(day)) {
                        return false;
                    }
                    return true;
                }
            },
            //投保人 台湾：   18<=age<=91  1927.8.14<=age<=2018.8.13 非台湾： 18<=age<=81  1937.8.14<=age<=2018.8.13（日期用2018.8.13为例子）
            'is18Picker': function (gets) {
                var obj = $('.layui-order-form #ApplicantBrithDate');
                if (obj.length > 0) {
                    _gsq.push(["track", "c_interact", { c_page_cate: "保单页", c_botton_cate: "保单页信息填写", c_botton_loc: "出生日期", c_button_name: "投保人", c_botton_url: "-", c_pro_name: $("input[name='productName']").val() }]);

                    var UUserDate = obj.val();
                    var myDate = new Date();
                    var month = myDate.getMonth() + 1;
                    var day = myDate.getDate();
                    var age = myDate.getFullYear() - UUserDate.substring(0, 4);
                    var prodCode = $("#ProductCode").val();

                    var month1 = myDate.getMonth() + 1 - UUserDate.substring(5, 7);
                    var day1 = myDate.getDate() + 1 - UUserDate.substring(8, 10);
                    var age1 = myDate.getFullYear() - UUserDate.substring(0, 4);

                    if (UUserDate.length == 10) {
                        if (age < 18 || (age == 18 && UUserDate.substring(5, 7) > month) || (age == 18 && UUserDate.substring(5, 7) == month && UUserDate.substring(8, 10) > day)) {
                            obj.attr('errormsg', '投保人年龄必须大于或等于18岁');
                            return "投保人年龄必须大于或等于18岁";
                        }
                        if (prodCode != "021085") {
                            if (age1 > 81 || (age == 81 && month1 > 0) || (age == 81 && month1 == 0 && day1 > 0)) {
                                obj.attr('errormsg', '投保人年龄必须小于或等于80岁');
                                return "投保人年龄必须小于或等于80岁";
                            }
                        }
                        else {
                            if (age1 > 91 || (age == 91 && month1 > 0) || (age == 91 && month1 == 0 && day1 > 0)) {
                                obj.attr('errormsg', '投保人年龄必须小于或等于90岁');
                                return "投保人年龄必须小于或等于90岁";
                            }
                        }
                    }
                }
            },
            // Update 2022.01.05 for 一生康美 Start
            //被保人出生日期 被保人： 台湾：   1<=age<91  1927.8.14<age<=2018.8.14 非台湾： 1<=age<81  1937.8.14<age<=2018.8.14 （日期用2018.8.13为例子）
            'is1Picker': function (gets) {
             
                var obj = $('.layui-order-form #InsuredBrithDate');
                if (obj.length > 0) {
                    _gsq.push(["track", "c_interact", { c_page_cate: "保单页", c_botton_cate: "保单页信息填写", c_botton_loc: "出生日期", c_button_name: "被保险人", c_botton_url: "-", c_pro_name: $("input[name='productName']").val() }]);

                    var birthday = $(obj).val();
                    if (birthday.length == 10) {
                        var policyStartDate = $("#PolicyStartDate").val();
                        var min = parseInt($("#HidminOld").val());
                        var max = parseInt($("#HidmaxOld").val());
                        if (!DateIsInRange(birthday, policyStartDate, min, max)) {
                            if ($("input[name='ProductCode']").val() == '180301' || $("input[name='ProductCode']").val() == '18030101' || $("input[name='ProductCode']").val() == '180302' || $("input[name='ProductCode']").val() == '020606' || $("input[name='ProductCode']").val() == '0206062') {
                                // 年龄不符合弹窗提醒
                                checkInsuredAge();
                            }
                            //var errmsg = "被保险人年龄须在(" + min + "," + max + ")之间";
                            var errmsg = "年龄" + min + "-" + max + "周岁";
                            obj.attr('errormsg', errmsg);
                            return false;
                        }

                    }
                }
                               //校验被保人年龄是否超出产品的限制
                function DateIsInRange(birthday, policyStartDate, min, max) {
                    //get date type
                    var birth = new Date(Date.parse(birthday.replace(/-/g, "/")));
                    var birthyear = birth.getFullYear();
                    var birthMonth = birth.getMonth();
                    var birthDayNum = birth.getDate();

                    //policy duration is from policy start date, not today[Bright 20140710]
                    var now = new Date(Date.parse(policyStartDate.replace(/-/g, "/")));
                    var nowyear = now.getFullYear();
                    var nowMonth = now.getMonth();
                    var nowDay = now.getDate();
                    //alert(birthMonth);
                    //check whehter it is less than min
                    if (nowyear - birthyear < min) {
                        return false;
                    }
                    //year is same, will check month and days
                    else if (nowyear - birthyear == min) {
                        //check month
                        if (nowMonth - birthMonth > 0) {
                            return true;
                        }
                        else if (nowMonth - birthMonth < 0) {
                            return false;
                        }
                        else if (nowMonth - birthMonth == 0) {
                            //check day
                            if (birthDayNum - nowDay > 0) {
                                return false;
                            }
                            else {
                                return true;
                            }
                        }
                    }
                    else {
                        //check whehter it is more than max year old
                        if (nowyear - birthyear > max) {
                            return false; //more than max year old
                        }
                        else if (nowyear - birthyear == max) {
                            //check month
                            if (nowMonth - birthMonth < 0) {
                                return true;
                            }
                            else if (nowMonth - birthMonth > 0) {
                                return false;
                            }
                            else if (nowMonth - birthMonth == 0) {
                                //check day
                                if (birthDayNum - nowDay > 0) {
                                    return true;
                                }
                                else {
                                    return false;
                                }
                            }
                        }
                        else {
                            return true;
                        }
                    }
                };
            },
            // Update 2022.01.05 for 一生康美 End
            'space': function (gets,obj) {
                if (!!gets) {
                    if (obj != undefined && obj.length > 0) {
                        if (obj[0].id == 'ApplicantLiveCity')
                            _gsq.push(["track", "c_interact", { c_page_cate: "保单页", c_botton_cate: "保单页信息填写", c_botton_loc: "所在地", c_button_name: "投保人", c_botton_url: "-", c_pro_name: $("input[name='productName']").val() }]);
                        else
                            _gsq.push(["track", "c_interact", { c_page_cate: "保单页", c_botton_cate: "保单页信息填写", c_botton_loc: "所在地", c_button_name: "被保险人", c_botton_url: "-", c_pro_name: $("input[name='productName']").val() }]);

                        if (obj[0].id == 'ApplicantLiveAddress')
                            _gsq.push(["track", "c_interact", { c_page_cate: "保单页", c_botton_cate: "保单页信息填写", c_botton_loc: "详细地址", c_button_name: "投保人", c_botton_url: "-", c_pro_name: $("input[name='productName']").val() }]);
                        else
                            _gsq.push(["track", "c_interact", { c_page_cate: "保单页", c_botton_cate: "保单页信息填写", c_botton_loc: "详细地址", c_button_name: "被保险人", c_botton_url: "-", c_pro_name: $("input[name='productName']").val() }]);
                    }
                }
                if (gets.trim() == "" || gets == "请填写详细地址" || gets == "请选择居住地址" || gets.indexOf("格式不正确") != -1 || gets == '请选择证件类型' || gets == '请正确填写地址' || gets == '请选择' || gets == '请填写' || gets == '请选择职业与类别') {
                    arguments[1].addClass('Validform_error');
                    return false;
                }
                return true;
            }
        },
        beforeCheck: function () {
            // UP：2020.02.22
            $('.layui-order-form input:visible').each(function (ind) {
                var _this = $(this);
                if( (_this.hasClass('Validform_error')&&_this.val().length==0) || (!_this.hasClass('Validform_error')&&_this.val().length==0) ){
                    if(_this.attr('ignore')==undefined)
                        _this.addClass('Validform_error').val(_this.attr('nullmsg'));
                }
            })
            if ($('input:visible.Validform_error').length > 0) {
                return false;
            }
            $('input.Validform_error').val('');
            $('.layui-order-form input:visible').blur();
        },
        beforeSubmit: function () {
            //最后一步【校验】画面信息
            //var resultFlag = validatePage(false);
            //if (!resultFlag) {
            //    return false;
            //}

            //关闭编辑状态
            //如果页面上提示重现投被保关系，不继续提交验证
            if ((!$(".layui-order-form .step-form").find(".tip-relation").is(":hidden")) && (!$(".layui-order-form .step-form").find(".tip-repeatinsured").is(":hidden")) && (!$(".layui-order-form .step-form input").hasClass('Validform_error')) && (!$(".layui-order-form .step-form input").hasClass('Validform_error2'))) {
                $("#editstatus").val("false");
            }

            //异步保存数据
            formSubmitByAjax(true);

            //除了最后一次询价 其他询价都是异步做的（最后一次询价是同步做的）
            var resultFlag = QuotoPriceMethod(true);
            if (!resultFlag) {
                return false;
            }
            if (!orderconfirm) {
                return false;
            }
        }
    })

}







$.fn.smartFloat = function () {
    var position = function (element) {
        var top = element.position().top, pos = element.css("position");
        $(window).scroll(function () {
            var scrolls = $(this).scrollTop();
            if (scrolls > top) {
                element.css({
                    position: "fixed",
                    top: 0
                }).addClass("shadow");
            } else {
                element.css({
                    position: pos,
                    top: top
                }).removeClass("shadow");
            }
        });
    };
    return $(this).each(function () {
        position($(this));
    });
};











function time(o) {
    if (o.className == 'disabled')
        return false;
    countdowncountdown(o)
}
function countdowncountdown(o) {
    if (wait == 0) {
        o.removeAttribute("disabled");
        o.innerHTML = "发送动态验证码";
        o.className = '';
        wait = 60;
    } else {
        o.setAttribute("disabled", true);
        o.innerHTML = wait + "秒后重发";
        o.className = 'disabled';
        wait--;
        setTimeout(function () { countdowncountdown(o) }, 1000)
    }

}



//JQuery 扩展
jQuery.fn.extend({
    serializeA: function () {
        return $.param(this.map(function () {
            return this.elements ? jQuery.makeArray(this.elements) : this;
        })
            .filter(function () {
                return this.name &&
                    (this.checked || /select|textarea/i.test(this.nodeName) ||
                        /text|hidden|password|search/i.test(this.type));
            })
            .map(function (i, elem) {
                var val = jQuery(this).val();

                return val == null ?
                    null :
                    jQuery.isArray(val) ?
                        jQuery.map(val, function (val, i) {
                            return { name: elem.name, value: val };
                        }) :
                        { name: elem.name, value: val };
            }).get());
    },
});


// Update Start by Kevin 2019/01/21 Hotfix_AddAdobeInspector etravel的购买页面增加ADOBE的监测代码和检测数据PC，WAP，WECHAT端
if (!window.digitalData) {
    //var digitalData = {};
    var digitalData = {
        'siteInfo': {
            'siteName': 'aig cn',
            'country': 'cn',
            'language': 'cn',
            'businessUnit': 'property-and-casualty',
            'siteCategory1': 'individuals:travel-insurance',
            'siteChannel': 'individuals'
        },
        'pageInfo': {
            'pageName': 'aig cn:individuals:travel-insurance',
            'pageType': 'text/html; charset=UTF-8',
            'pageTitle': document.title,
            'pageCategory': 'purchase page',
            'PageFrom': (($("#PartnerCode").val() == "wechat") ? "WECHAT" : "MOBILE"),
            'pagePath': window.document.location.href,
            'PageEvent': ''
        },
        'formInfo': {
            'formName': 'v2-order-form',
            'formId': 'v2-order-form',
            'formType': 'post'
        },
        'cartInfo': {
            'totalPeople': '',
            'childPeople': '',
            'adultPeople': '',
            'productCode': $("#ProductCode").val(),
            'planCode': $("#PlanCode").val(),
            'productName': $("#productName").val(),
            'planName': $("#PlanName").val(),
            'destination': '',
            'startDate': $("#PolicyStartDate").val(),
            'endDate': $("#PolicyEndDate").val(),
            'delayAdditional': ($("#DelayAdditional").val() == "1" ? "医疗补充版" : "未选"),
            'during': $("#DateDuration").val(),
        },
        'transactionInfo': {
            'transactionID': '',
            'transactionStatus': '',
            'transactionItems': {
                'product': {
                    'name': '',
                    'plan': '',
                    'area': '',
                    'startdate': '',
                    'enddate': '',
                    'plus': '',
                    'productCode': '',
                    'fullYearFlag': '',
                    'planCode': '',
                    'totalPrice': ''
                    //},
                    //'applicant': {
                    //    'name': '',
                    //    'sex': '',
                    //    'birthday': '',
                    //    'idtype': '',
                    //    'idno': '',
                    //    'mobile': '',
                    //    'email': ''
                    //},
                    //'insured': [
                    //    {
                    //        'relation': '',
                    //        'name': '',
                    //        'sex': '',
                    //        'birthday': '',
                    //        'idtype': '',
                    //        'idno': '',
                    //        'mobile': ''
                    //    }
                    //],
                    //'express': {
                    //    'name': '',
                    //    'mobile': '',
                    //    'province': '',
                    //    'address': ''
                }
            }
        },
        'paymentInfo': {
            //'paymentId': '',
            'transactionId': '',
            //'payNo': '',
            'payType': '',
            'payAmout': '',
            'payDatetime': ''
        },
        'userInfo': {
            'userLoginStatus': '',
            'userProfileId': '',
            'userName': '',
            'userMobile': ''
        }
    };
    console.log(digitalData);
}


//更新全局变量 Adobe监测代码
function UpdateAdobeInspector(updateFlag, eventName, userName, userMobile, userLoginStatus) {

    //digitalData = {
    //    'pageInfo': {
    //        'pagePath': window.document.location.href,
    //        'PageEvent': eventName
    //    },
    //};

    digitalData.pageInfo.pagePath = window.document.location.href;
    digitalData.pageInfo.PageEvent = eventName;

    // 更新购物车
    if (updateFlag == "1") {
        //digitalData = {
        //    'cartInfo': {
        //        'totalPeople': $("#totalinsurednum").val(),
        //        'childPeople': $("#childinsurednum").val(),
        //        'adultPeople': $("#adultinsurednum").val(),
        //    }
        //}
        digitalData.cartInfo.totalPeople = $("#totalinsurednum").val();
        digitalData.cartInfo.childPeople = $("#childinsurednum").val();
        digitalData.cartInfo.adultPeople = $("#adultinsurednum").val();

        digitalData.transactionInfo = {
            'transactionID': $("#TransactionId").val(),
            'transactionStatus': 'waiting for pay',
            'transactionItems': {
                'product': {
                    'name': $("#productName").val(),
                    'plan': $("#PlanName").val(),
                    'area': '',
                    'startdate': $("#PolicyStartDate").val(),
                    'enddate': $("#PolicyEndDate").val(),
                    'plus': ($("#DelayAdditional").val() == "1" ? "医疗补充版" : "未选"),
                    'productCode': $("#ProductCode").val(),
                    'fullYearFlag': '',
                    'planCode': $("#PlanCode").val(),
                    'totalPrice': $("#PolicyTotalPrice").val()
                }
            }
        };
    }

    // 更新订单
    if (updateFlag == "2") {
        //digitalData = {
        //    'transactionInfo': {
        //        'transactionID': $("#TransactionId").val(),
        //        'transactionStatus': '1',
        //        'transactionItems': {
        //            'product': {
        //                'name': $("#productName").val(),
        //                'plan': $("#planName").val(),
        //                'area': '',
        //                'startdate': $("#PolicyStartDate").val(),
        //                'enddate': $("#PolicyEndDate").val(),
        //                'plus': $("#DelayAdditional").val(),
        //                'productCode': $("#ProductCode").val(),
        //                'fullYearFlag': ''),
        //                'planCode': $("#planCode").val(),
        //                'totalPrice': $("#PolicyTotalPrice").val(),
        //            }
        //        }
        //    }
        //};
        digitalData.transactionInfo = {
            'transactionID': $("#TransactionId").val(),
            'transactionStatus': '1 - waiting for pay',
            'transactionItems': {
                'product': {
                    'name': $("#productName").val(),
                    'plan': $("#PlanName").val(),
                    'area': '',
                    'startdate': $("#PolicyStartDate").val(),
                    'enddate': $("#PolicyEndDate").val(),
                    'plus': ($("#DelayAdditional").val() == "1" ? "医疗补充版" : "未选"),
                    'productCode': $("#ProductCode").val(),
                    'fullYearFlag': '',
                    'planCode': $("#PlanCode").val(),
                    'totalPrice': $("#PolicyTotalPrice").val()
                }
            }
        };
    }

    // 更新登陆信息
    if (updateFlag == "3") {
        //digitalData = {
        //    'userInfo': {
        //        'userLoginStatus': userLoginStatus,
        //        'userProfileId': userName,
        //        'userName': userName,
        //        'userMobile': userMobile
        //    }
        //};

        digitalData.userInfo = {
            'userLoginStatus': userLoginStatus,
            'userProfileId': userName,
            'userName': userName,
            'userMobile': userMobile
        };
    }

}

// Update End by Kevin 2019/01/21 Hotfix_AddAdobeInspector etravel的购买页面增加ADOBE的监测代码和检测数据PC，WAP，WECHAT端

//add by eren 20191029 去除工作单位全空格情况 start
$(document).on('blur', '.layui-order-form #InsuredJobCompany', function () {
    $(this).val($(this).val().trim());
});
$(document).on('blur', '.layui-order-form #ApplicantJobCompany', function () {
    $(this).val($(this).val().trim());
});
//add by eren 20191029 去除工作单位全空格情况 end
//add by eren 20191029 验证生日是否符合start
function checkBirthday_applicant() {
    var obj = $('.layui-order-form #ApplicantBrithDate');
    if (obj.length > 0) {
        var UUserDate = obj.val();
        var myDate = new Date();
        var month = myDate.getMonth() + 1;
        var day = myDate.getDate();
        var age = myDate.getFullYear() - UUserDate.substring(0, 4);
        var prodCode = $("#ProductCode").val();

        var month1 = myDate.getMonth() + 1 - UUserDate.substring(5, 7);
        var day1 = myDate.getDate() + 1 - UUserDate.substring(8, 10);
        var age1 = myDate.getFullYear() - UUserDate.substring(0, 4);

        if (UUserDate.length == 10) {
            if (age < 18 || (age == 18 && UUserDate.substring(5, 7) > month) || (age == 18 && UUserDate.substring(5, 7) == month && UUserDate.substring(8, 10) > day)) {
                obj.attr('errormsg', '投保人年龄必须大于或等于18岁');
                return false;
            }
            if (prodCode != "021085") {
                if (age1 > 81 || (age == 81 && month1 > 0) || (age == 81 && month1 == 0 && day1 > 0)) {
                    obj.attr('errormsg', '投保人年龄必须小于或等于80岁');
                    return false;
                }
            }
            else {
                if (age1 > 91 || (age == 91 && month1 > 0) || (age == 91 && month1 == 0 && day1 > 0)) {
                    obj.attr('errormsg', '投保人年龄必须小于或等于90岁');
                    return false;
                }
            }
            return true;
        }
        return false;
    }
}

function checkBirthday_insured() {
    var obj = $('.layui-order-form #InsuredBrithDate');
    if (obj.length > 0) {
        var birthday = $(obj).val();
        if (birthday.length == 10) {
            var policyStartDate = $("#PolicyStartDate").val();
            var min = parseInt($("#HidminOld").val());
            var max = parseInt($("#HidmaxOld").val());
            // Update 2022.01.05 for 一生康美 Start

            //Update by Amy at 2021.06.01 for 添加宝贝无忧 Start
            // Update by Xu Lei at 2020.11.02 for 添加百万医疗DTC Start
            if (!DateIsInRange(birthday, policyStartDate, min, max)) {
                if ($("input[name='ProductCode']").val() == '180301' || $("input[name='ProductCode']").val() == '18030101' || $("input[name='ProductCode']").val() == '180302' || $("input[name='ProductCode']").val() == '020606' || $("input[name='ProductCode']").val() == '0206062') {
                    min = '30天';
                    // 年龄不符合弹窗提醒
                    checkInsuredAge();
                }
                //var errmsg = "被保险人年龄须在(" + min + "," + max + ")之间";
                var errmsg = "年龄" + min + "-" + max + "周岁";
                obj.attr('errormsg', errmsg);
                return false;
            }
            // Update by Xu Lei at 2020.11.02 for 添加百万医疗DTC End
            //Update by Amy at 2021.06.01 for 添加宝贝无忧 End

            // Update 2022.01.05 for 一生康美 End

            return true;
        }
        return false;
    }
    return false;

    //校验被保人年龄是否超出产品的限制
    function DateIsInRange(birthday, policyStartDate, min, max) {
        //get date type
        var birth = new Date(Date.parse(birthday.replace(/-/g, "/")));
        var birthyear = birth.getFullYear();
        var birthMonth = birth.getMonth();
        var birthDayNum = birth.getDate();

        //policy duration is from policy start date, not today[Bright 20140710]
        var now = new Date(Date.parse(policyStartDate.replace(/-/g, "/")));
        var nowyear = now.getFullYear();
        var nowMonth = now.getMonth();
        var nowDay = now.getDate();
        //alert(birthMonth);
        //check whehter it is less than min
        if (nowyear - birthyear < min) {
            return false;
        }
        //year is same, will check month and days
        else if (nowyear - birthyear == min) {
            //check month
            if (nowMonth - birthMonth > 0) {
                return true;
            }
            else if (nowMonth - birthMonth < 0) {
                return false;
            }
            else if (nowMonth - birthMonth == 0) {
                //check day
                if (birthDayNum - nowDay > 0) {
                    return false;
                }
                else {
                    return true;
                }
            }
        }
        else {
            //check whehter it is more than max year old
            if (nowyear - birthyear > max) {
                return false; //more than max year old
            }
            else if (nowyear - birthyear == max) {
                //check month
                if (nowMonth - birthMonth < 0) {
                    return true;
                }
                else if (nowMonth - birthMonth > 0) {
                    return false;
                }
                else if (nowMonth - birthMonth == 0) {
                    //check day
                    if (birthDayNum - nowDay > 0) {
                        return true;
                    }
                    else {
                        return false;
                    }
                }
            }
            else {
                return true;
            }
        }
    };
}
//add by eren 20191029 验证生日是否符合end